From: James M. <jm...@tr...> - 2003-12-15 17:34:58
|
Hi all, To the fine folks who develop slashcode regularly, thanks for your work. What I am most concerned with at the moment is migrating my website style from tables to CSS. (By way of background, I use slashcode more as a library than as a readymade website. I use the login and authentication stuff without ever looking at the code, I use the DB interface, and I use the template toolkit display calls. And of course, I use the admin interface to edit templates. ) Over the weekend I finally had a look at that write up on A List Apart mentioned a few weeks ago in slashdot. Now I've got one site rendering in xhtml strict, with a css style sheet, and not a table tag in site. But to do so I push in lots of stuff for the CSS template through a hashref when I call the make header routine, and most egregiously, I hacked the menu system, overloading the "value" entries to also set the id tag for each list item, as in: <ul>[% FOR i = items %] [%- myvalue = i.value -%] [%- matches = myvalue.match('(op).(\w+)\"') %] <li id="nav-[%- matches.1 -%]"><a [% i.value %]>[% i.label %]</a></li> [% END %]</ul> Couple of thoughts on this (having not looked at CVS code, btw). First, I can only seem to access the menu entries in the menus table by a mysql console, not the admin interface. Is this a feature or a bug? Second, the menus table could use another hook or two for style sheets, to avoid my ugly text parsing hack. Something like styleid varchar (20) NOT NULL, styleclass varchar(20) NOT NULL default "menuitem", would probably do it. I would do that, but the code that renders the menu would need to be changed, thus breaking my compatibility with the slash libraries. (Hmm, I just thought that maybe it is possible to subclass something like the Environment module to override that function???) Third, I am not sure whether it is appropriate to put the css style sheet in a separate, static file, or render it with a template. I do the latter right now, since my usage sets the names of style ids on the fly based on passed arguments, so that I can add to the menu with minimal fuss, as in: ... perl to get an arraref to my menu values (parsing op="text" entries), passed as navids to template ... [% FOREACH nid = navids %] #[%- nid %] #nav-[%- nid %][%- ', ' UNLESS loop.last -%] [% END %] { background-position:0 -150px; border-width:0; } [% FOREACH nid = navids %] #[%- nid %] #nav-[%- nid %] a[%- ', ' UNLESS loop.last -%] [% END %] { background-position:100% -150px; padding-bottom:5px; color:#333; } (which copies shamelessly a technique from another article in A List Apart) Any thoughts on static versus dynamic css? I think the bandwidth savings quoted by the "recoding slashdot" article depend upon a cached css file. Perhaps if the css file is dynamically rendered, then the savings go poof. An alternative is to have a mix; some css static, other stuff dynamic, as files static_layout.css, static_markup.css, and then any dynamic styles pushed into the header after the stylesheet include commands. But I think the attraction of slashcode to me is dynamically generating and rendering content. Philosophically, should the the css be considered decoration that can be static, like the various icons and borders, or dynamic, like the content? I think it should be dynamic, since it opens up more possibilities (such as the extensible menu styles above), and it puts the code in the db where it can be manipulated through temlate toolkit. hoping this long post is appropriate for this list, James |