Display titles of containing folders
How can I display titles of folder, its parent folder etc. that contain a given ZClass if I iterate over a Catalog? Catalog_Art is a catalog of Articles. Given the following dtml method I would like to display the "path" to the article. Path means the titles of folders that the Article instance is located in: <table> <dtml-in Catalog_Art> <tr><td><dtml-var mypath></td></tr> </dtml-in> </table> mypath is a Python Script that I cannot find a way to create :-( I head a good start: fullpath=context.getpath(context.data_record_id) fullpath=fullpath[1:] fullpath=string.replace(fullpath,"/",".") subfolder=fullpath[0:string.rfind(fullpath,".")] folder=subfolder[0:string.rfind(subfolder,".")] at this point folder=="folder_a" and subfolder=="folder_a.folder_aa". But what next? I cannot run folder_title=getattr(folder,"title"), because getattr does not work that way, and I cannot run eval(), because it is not allowed in Python Scripts. -- Milos Prudek
Hi, --On Montag, 26. November 2001 21:15 +0100 Milos Prudek <milos.prudek@tiscali.cz> wrote:
How can I display titles of folder, its parent folder etc. that contain a given ZClass if I iterate over a Catalog?
Catalog_Art is a catalog of Articles.
Given the following dtml method I would like to display the "path" to the article. Path means the titles of folders that the Article instance is located in:
<table> <dtml-in Catalog_Art> <tr><td><dtml-var mypath></td></tr> </dtml-in> </table>
mypath is a Python Script that I cannot find a way to create :-( I head a good start:
fullpath=context.getpath(context.data_record_id) fullpath=fullpath[1:] fullpath=string.replace(fullpath,"/",".") subfolder=fullpath[0:string.rfind(fullpath,".")] folder=subfolder[0:string.rfind(subfolder,".")]
at this point folder=="folder_a" and subfolder=="folder_a.folder_aa". But what next? I cannot run folder_title=getattr(folder,"title"), because getattr does not work that way, and I cannot run eval(), because it is not allowed in Python Scripts.
Sure, but if you touch each object anyway, you dont need the catalog. I can think of two ways to solve it a bit cleaner: Record the title in the catalog, you can ilteratively search for the sub paths which should give you only one result - the folder along with its title. The other way would be a method which returns your path title chain as a string (in the ZClass) and catalog it with every object. Regards Tino
Sure, but if you touch each object anyway, you dont need the catalog.
What do you mean by "touching"? I don't think that I touch the objects. I need to iterate over all objects (ZClass instances) distributed in three-level folder tree. Catalog provides a simple, "flat" model to iterate over it with <dtml-in>.
Record the title in the catalog, you can ilteratively search for the sub paths which should give you only one result - the folder along with its title.
I do not understand. Can you describe it in more detail?
The other way would be a method which returns your path title chain as a string (in the ZClass) and catalog it with every object.
Yes, but then folder renaming would require changing a "titlepath" property in all instances located in that folder. That's something that I'd like to evade. Thanks! -- Milos Prudek
participants (2)
-
Milos Prudek -
Tino Wildenhain