Re: [Rest2web-develop] Section headers
Brought to you by:
mjfoord
From: martin f k. <ma...@ma...> - 2006-08-05 21:42:30
|
also sprach martin f krafft <ma...@ma...> [2006.08.04.1454 +0100]: > here's another question for you... take a look at > http://ailab.ch.org and take note of the section tabs on the left > hand side... if you click on one, it gets you to the subsection and > then stays highlighted. FWIW, I got it working the way I want it (I think), see http://martin-krafft.net/phd/ . The CSS that makes it look good (IMHO at least) is http://martin-krafft.net/phd/css/screen.css . The code I use for template.txt is below. The system works with uservalues to be defined in the base page of a category: uservalues category_name: Contact category_prio: 99 /uservalues Both values are optional, but at least one has to exist, or else the system does not recognise the page as a category definition. If the name is left out, the link_title (or page_title) is used. If the priority is left out, 50 is used. Tabs are sorted according to priority, then category name. This can probable be improved, and added to functions.py at one point. Thanks, Michael, for your help! <div id=3D"nav"> <# def category_list(indextree): l =3D [] uv =3D indextree.get('uservalues', {}) if uv.has_key('category_name') \ or uv.has_key('category_prio'): prio =3D uv.get('category_prio', 'default') if prio =3D=3D 'default': prio =3D 50 l.append((int(prio),=20 uv.get('category_name', indextree['link-title']), indextree['target'], indextree['thispage'])) if indextree['pages'] is not None: for p in indextree['pages']: l +=3D category_list(p) l.sort() return l def is_current_category(page, category): p =3D page while p is not None: uv =3D p.get('uservalues', {}) cat_name =3D uv.get('category_name', p['link-title']) if cat_name =3D=3D category: # only return true for the site root if the current page is the s= ite # root. if we ended up at the site root because no matching categ= ory # was found, return false return p['target'] =3D=3D page['target'] or p.get('parent') is no= t None p =3D p.get('parent', None) return False l =3D category_list(indextree) if len(l) > 0: print '<ul id=3D"global-links">' from sys import stdout for i in l: print '<li' if is_current_category(thispage, i[1]): print ' class=3D"current"' print '><a href=3D"%s">%s</a></li>' % (i[2], i[1]) #> </div> --=20 martin; (greetings from the heart of the sun.) \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck =20 spamtraps: mad...@ma... =20 "they that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -- benjamin franklin |