How to make a simple site map simply
Created by .
Last modified on 2003/08/05.
This code is too simple for a product but I thought
that beginners may get something from this, if not the
reuse of the code as is.
On my site I wanted a one page site map showing the
structure of my site with all the important pages available.
The Zope folder structure gave almost gave me this but the
trick was how to weed out all the code type objects from
the pages that are of interest to a user. I did this by only
showing pages that had a title. Whats more I didn't show folders
that had no title either. This meant it was resonably simple
to hide wizard type pages that required input inside an
untitled folder.
Anyway, heres the code. Below is the simple SiteMap document
that starts a recursive DTML method call.
<!--#var standard_html_header-->
<!--#with aq_parent-->
<!--#var recurseFolder-->
<!--#/with-->
<!--#var standard_html_footer-->
The DTML method "recurseFolder" looks like this
<ul>
<!--#in "objectItems(['DTML Document','Image','File'])"-->
<!--#if "AUTHENTICATED_USER.has_permission('View',_.getitem('id',1))"-->
<!--#if "_.getitem('id',1) != 'index_html' and title != ''"-->
<li><a href="<!--#var "absolute_url()"-->"><!--#var title--></a>
<!--#if "(ZopeTime() - bobobase_modification_time()) < 14"-->
<img src="<!--#var "images.imgNew.absolute_url()"-->" alt="*NEW*">
<!--#/if-->
</li>
<!--#/if-->
<!--#/if-->
<!--#/in-->
<!--#in "objectItems(['Folder'])"-->
<!--#if "title != '' and AUTHENTICATED_USER.has_permission('View',_.getitem('id',1))"-->
<li>
<a href="<!--#var "_.getitem(id).absolute_url()"-->"><!--#var title--></a>
</li>
<!--#with sequence-item-->
<!--#var recurseFolder-->
<!--#/with-->
<!--#/if-->
<!--#/in-->
</ul>
This code in the average case will produce a resonably good sitemap. It will
only have links to pages the current user can view. It will indicate which
documents have changed in the last 2 weeks.
|