Hi list, Another newbie-ish question, looked in the FAQ but couldn't find an example that was clear enough... I'm recreating the navbar in a plone portal by hand, looping over the plone folders in the root folder of the plone site. Ok, that's what I *want* to do, and need help from a zenmaster on how to do it within plone :^) The reason for this is that I'd like it to be dynamically-generated, based on the folders created; and hope to have a javascript-based dynamic menu populated by the objects within those root folders. So far, when I use examples of looping (via ZPT documentation), Plone throws a security error and refuses to cooperate. So I suppose the two questions are: 1) How do you do this in Plone? 2) Is there a better approach? -- mitchy
Mitch Pirtle wrote:
Hi list,
Another newbie-ish question, looked in the FAQ but couldn't find an example that was clear enough...
I'm recreating the navbar in a plone portal by hand, looping over the plone folders in the root folder of the plone site. Ok, that's what I *want* to do, and need help from a zenmaster on how to do it within plone :^) The reason for this is that I'd like it to be dynamically-generated, based on the folders created; and hope to have a javascript-based dynamic menu populated by the objects within those root folders. So far, when I use examples of looping (via ZPT documentation), Plone throws a security error and refuses to cooperate.
So I suppose the two questions are:
1) How do you do this in Plone?
2) Is there a better approach?
You might want to try using the ZCatalog (portal_catalog). Check out the news_slot (portal_skins/plone_templates/ui_slots/news_slot) in Plone for an example. The reason that I suggest the catalog is that you will then be able to sort on any indexed and sortable field. So, if you wanted to add a property to your plone folders called "display_order" (if you do this, consider making your own product/content type with all the custom properties you will want), you could place them as you like. Also, you can only return meta_type "Plone Folder" and that will prevent other unwanteds from showing up. duncan
On Tue, 2003-09-23 at 11:18, Duncan McGreggor wrote:
Mitch Pirtle wrote:
(I was asking about looping through Plone Folders)
You might want to try using the ZCatalog (portal_catalog). Check out the news_slot (portal_skins/plone_templates/ui_slots/news_slot) in Plone for an example. The reason that I suggest the catalog is that you will then be able to sort on any indexed and sortable field. So, if you wanted to add a property to your plone folders called "display_order" (if you do this, consider making your own product/content type with all the custom properties you will want), you could place them as you like. Also, you can only return meta_type "Plone Folder" and that will prevent other unwanteds from showing up.
Actually looked at the navigation slot, it does everything I need for the top level... The only thing remaining is the drop-down elements, I'll need some Javascript code and a way of tying (tieing?) the drop-down elements to the parent menu element. If anyone knows of a CMF/Plone-aware tool, please let me know. -- mitchy
Another newbie-ish question, looked in the FAQ but couldn't find an example that was clear enough...
I'm recreating the navbar in a plone portal by hand, looping over the plone folders in the root folder of the plone site. Ok, that's what I *want* to do, and need help from a zenmaster on how to do it within plone :^) The reason for this is that I'd like it to be dynamically-generated, based on the folders created; and hope to have a javascript-based dynamic menu populated by the objects within those root folders. So far, when I use examples of looping (via ZPT documentation), Plone throws a security error and refuses to cooperate.
So I suppose the two questions are:
1) How do you do this in Plone?
2) Is there a better approach?
Easy: create a ZPT in your skins folder (probably 'custom') named 'recurse':: <ul> <li tal:repeat="item here/objectValues"> <span tal:content="item/getId" tal:omit-tag="">An object</span> : <span tal:content="item/title" tal:omit-tag="">A title</span> <span tal:condition="python:item.meta_type=='Folder'" tal:content="structure item/recurse">A Folder listing</span> </li> </ul> Include this wherever you want, like in your header skin or in another ZPT that you can use as a slot like the NavTree (since you're using Plone.) You'll have to learn a little ZPT, of course, but it isn't so bad. The condition check is pretty primitive. Probably a better one would check for the presence of the objectValues method like tal:define="folderish nocall:item/objectValues" tal:condition="folderish | nothing" You could also check the CMF type of the object to only display Folders, etc. You can also of course condition the 'leaf' display to only display folders as well (since this code does a full site tree.) This will construct a nested HTML unordered list of your tree from the place where you called it (from inside a valid HTML page.) You can of course tweak the display code: I think you can see how you would use this to populate the data structure of whatever dynamic menus you're using. Consider using pure CSS menus rather than Javascript: http://www.meyerweb.com/eric/css/edge/menus/demo.html There are also products that will create site maps which you might be able to modify. Search around. --jcc -- "My point and period will be throughly wrought, Or well or ill, as this day's battle's fought."
participants (3)
-
Duncan McGreggor -
J. Cameron Cooper -
Mitch Pirtle