Site Navigation Table
Two Python scripts (which means two table styles), some pictures and a css file.
That is what this product contain.
(This is more a how-to than a product.)
But you better look at these pictures:
To make this scripts to work you must:
- Add property of root folder iconspath to keep the path to your icons.
I use LocalFS to point to a folder with gifs.
- Add a property of root folder bk_color which keep #5566aa or #99bbff if you want; the background color.
- Add a lot of folders with title
- Add a lot of DTML Documents with title
- Add a lot of WikiPages (no title - you don't need title)
- And add a lot of what ever you want, but set a title
- The Python script will
for i in self.objectItems(items):
and you call the script like that:
<dtml-var "navtable1(PARENTS[-1],Home
,/home.htm
,[ZWiki Page
,'DTML Document'])">
or <dtml-var "navtable1(PARENTS[-1],Home
,/home.htm
,['Folder'])">
- PARENTS[-1] is the root of your site
PARENTS[0] is the current folder.
use PARENTS[0] when you want to display a site map (nav table) from current folder.
- You need a title to your documents.
If that document don't have title - that means is not for public (not yet) so will not be listed on nav table (WikiPages are special, you know)
- Each document with title should have a property called ico which keep the icon image filename.
When the script build the nav table, it will append at iconspath the value from ico and will display a picture.
iconspath=/z/icons/
ico=book.gif
If you don't set an icon the script will use 'Leaf.gif' instead. Be sure you have this file.
The Python script
Title : Navigation Table version 2
Parameter List :self,t=Home
,a='',items=[Folder
,ZWiki Page
,'DTML Document'],f=1
The body:
#
#t =title of table
#a =link adress title
#items=list with zope items
#f =1 for table with width=100%
#
# set colors
c_border=#000000
c_title=#333399
c_body=#4444aa
ret='
ret=ret+
<table'
if f==1: ret=ret+ width="100%"
ret=ret+' border="0" cellspacing="0" cellpadding="1" bgcolor="'+c_border++"><tr><td>
ret=ret+<table width="100%" border="0" cellspacing="1" cellpadding="3">
ret=ret+'<tr><td align=left bgcolor="'+c_title+'"> <img src="/img/nav/bar.jpg" border=0> <a href="'+a+'" class="tmap2">+t+
</a> <img src="/img/nav/bar.jpg" border=0></td></tr>
ret=ret+
<tr><td bgcolor="'+c_body+">
for i in self.objectItems(items):
o=i[1] #the object
title=o.title
id=i[0]
if (title != '' and id != index_html
) or o.getNodeName()==ZWikiPage
:
#ret=ret+<img src="
#ret=ret+/img/nav/arr_left.gif
ret=ret+'<img src="'+self.iconspath
if o.hasProperty(ico
): ret=ret+o.ico
else: ret=ret+Leaf.gif
ret=ret+'"> <a href="'+o.absolute_url()+"
if o.hasProperty(tar
): ret=ret+'target="'+o.tar+'"
ret=ret+
class="map2" >+title+
</a><br>'
ret=ret+</td></tr></table></td></tr></table><br>
return ret
Parameters
#
#t =title of table
#a =link adress title
#items=list with zope items
#f =1 for table with width=100%
#
Sample:
<h1>Nav table 1</h1>
<dtml-var "navtable1(PARENTS[-1],Home
,/home.htm
,[ZWiki Page
,'DTML Document'],0)">
<h1>Nav table 2</h1>
<dtml-var "navtable2(PARENTS[-1],Home
,/home.htm
,[ZWiki Page
,'DTML Document'],0)">
Sort items
You may sort items into your generated table with:
lista=self.objectItems(items)
lista.sort()
for i in lista:
instead of using this :
for i in self.objectItems(items):
That's all! Tell me if you have questions.