Re: [Rest2web-develop] Section headers
Brought to you by:
mjfoord
From: martin f k. <ma...@ma...> - 2006-08-05 12:58:24
|
also sprach Michael Foord <mi...@pc...> [2006.08.05.1305 +0100]: > martin f krafft wrote: > >also sprach Michael Foord <mi...@pc...> [2006.08.05.1158 +0100]: > > =20 > >>Yes indextree['parent'] is always None. > >> =20 > > > >Ok. > > > > =20 > >>I *think* I see what you want to do. You want a single index page > >>which only shows pages from the selected section. I could probably > >>achieve that with javascript, but I wouldn't know how to do it > >>with CSS. :-) > >> =20 > > > >No no, much easier. I simply want a list of categories (let's not > >call them sections) as defined in the root, to show up on all pages > >of the site. I want one of those categories to be hilighted, > >depending on where we are in the site. > > > >Pseudocode: > > > > def current_url_matches_category(page, cat): > > // ... > > > > print '<ol id=3D"globalsect">' > > for cat in indextree['categories']: > > if current_url_matches_category(page, cat): > > print '<li class=3D"current">' + cat['link title'] + '</li>' > > else: > > print '<li><a href=3D"%s">%s</a></li>' % (cat['base_url'],=20 > > cat['link_title']) > > > > =20 > Hmm... on reading your pseudocode a bit more carefully.... :-) >=20 > You want every 'category' to have a 'base_url' as well. >=20 > This isn't something that is really directly available in rest2web - you= =20 > want global categories and information available to every page. >=20 > You could then set the category for each page in a uservalue. >=20 > How about if I add some 'globals' to rest2web that are available in=20 > every page? This would be a nice feature to have. Think site_title: <title><% title %> - <% site_title %></title> > You would set these in the top level, and could use them from every=20 > page. Your code would look something like (in your template) : >=20 > <# >=20 > # This code will only be executed once > # It could be kept in an external module and imported > if not categories in globalValues: > categories =3D {} > categories['category 1'] =3D {'base_url': '/url1', > 'link_title': 'link title 1'} > categories['category 2'] =3D {'base_url': '/url2', > 'link_title': 'link title=20 > 2'} =20 > globalValues['categories'] =3D categories >=20 > #> >=20 > Feel free to suggest a better name than globalValues. :-) >=20 > You could find a better way of setting up the categories than hardcoding= =20 > them into your code, based on the other values available to you. *You*=20 > still have to decide which is the base url for your categories though. Well, I think that subdirectories would make perfect sense. Now I have to figure out how to use the indextree structure: - how do I get a page's uservalues? In an earlier mail, you told me to use indextree['namespace']['myvalue'], but there is no item 'namespace' in the indextree structure. - how do I get at other restindex values? For instance, if I needed to read a page's page-title, how would I do that. > If you then set a 'category' uservalue in each page, your pseudocode=20 > becomes : >=20 > <# >=20 > print '<ol id=3D"globalsect">' > for (catName, cat) in globalValues['categories'].items(): > if category =3D=3D catName: > print '<li class=3D"current">' + cat['link_title'] + '</li>' > else: > print '<li><a href=3D"%s">%s</a></li>' % (cat['base_url'],=20 > cat['link_title']) >=20 > #> >=20 > How does that seem ? (I am not trimming the reply because this goes out to the mailing list). --=20 martin; (greetings from the heart of the sun.) \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck =20 spamtraps: mad...@ma... =20 nasa spent 2 billion dollars on the research of a ballpoint pen that could write on everything, even upside down, under water, or at extreme temperatures; the russians used a pencil. (but see: http://www.snopes.com/business/genius/spacepen.asp) |