[ZPT] Templates - Automatic Navigation

Klinger Wolfgang wolfgang@wazum.com
Mon, 17 Dec 2001 19:22:14 +0100


Hiya!

I use this combination:

--
a python script:

results=[]
for object in context.root_folder.objectValues():
  if object.getProperty('menuentry'):
      results.append(object)
return results

--
and this zpt code in the master template:

<div id="othersections" tal:define="sequence python:root.menu_list()">
  <tal:block repeat="item sequence">
    <div class="menu"
         tal:condition="python:not(here==item)">
      <a tal:define="item_absurl python:item.getAbsoluteUrl()"
         tal:attributes="href string:${absurl}/index_html"
         tal:content="python:item.getCurrentTitle()" href="#">link to
folder</a>
    </div>
  </tal:block>
</div>
--

I use a property of the folder called "menuentry" to define
what should show up in the list ...
you can also call the python script recursively with a little
bit of fine-tuning of the above code fragment ...

oh, yeah, the getAbsoluteUrl() and getCurrentTitle() method
are scripts with a proxy role, so you can use it on protected folders too!
there's an example in the "zpt examples" on how to skip
them, if you don't want them to show up, or you just don't
set the property ... there are so many solutions ... ;-)
you don't need such mechanism?, just use item/absolute_url ..


hope this works for you

Wolfgang
http://www.wazum.com/
wolfgang@wazum.com

----------------------------------------------------
Sam Collett wrote:
----------------------------------------------------


What is wrong with the following?

<ul>
      <li tal:repeat="example python:BASE2.objectValues('Folder')">
        <a href="example"
           tal:attributes="href example/getId"
           tal:content="example/title">Example Title</a>
      </li>
    </ul>

I want to go through all folders in the folder Test and build a menu as
follows:

Test <---this is not a link as it is the current directory
Folder1 <---this is a link
Folder2 <---this is a link
Folder3 <---this is a link

Test is the root directory.

When I click on Folder1 (a subfolder in Test), I want the same menu with the
link to folder1 disabled ie:

Test <---this is a link
Folder1 <---this is not a link as it is the current directory
Folder2 <---this is a link
Folder2 <---this is a link

The same thing should happen with Folder2. I may also want to not display
certain folders (images / css / scripts), how would I go about doing this
with page templates?

TIA

_______________________________________________
ZPT mailing list
ZPT@zope.org
http://lists.zope.org/mailman/listinfo/zpt