Hello-
I have not done a lot of theme hacking, but it seems to me that generally a theme is composed of static CSS and dynamically created (X)HTML. I am wondering if it is also possible to create dynamic CSS.
For example, in the current system, it is easy to create zebra striping by alternating classes on markup (say block divs). By alternating between .zebra1 and .zebra2, a theme creator can highlight every other block on a page. Of course, the classes themselves are defined in a static CSS file that is fetched from the server.
I was recently looking at Eric Meyer's Color Blender:
http://www.meyerweb.com/eric/tools/color-blend/
And I thought: wouldn't it be cool to do this programmatically on the server side? (To fade my blocks down the screen, for example.)
The obvious solution would be to tag each block with .fadeN class, where N is updated for each block. After I made all the blocks, I could go back and make N classes, each with a different color, faded from color1 to color2.
Is this possible? It requires the construction of a CSS file on the fly. I could not just add the styles inline, because I don't know how many blocks there are until the end (something of a halting problem).
It would be easy to link to 'dynamic.css' in the file (this can be done statically), but how would I get the dynamic.css file properly served to the user? Moreover, it might be better to code each .css file with a unique identifier, so that the styles won't be improperly cached.
Another option might be to make an inline <style> ... </style> section and stick it back in the DOM. Of the available options, this sounds like the easiest.
In the end, it might be best to create something like the forms API to manage dynamic CSS. It could be a very powerful feature, and easily encapsulated into a few functions (add_css(), render_css(), etc):
<?php $css['classname1']['classname2'] = array( 'color' => '#12AB00', 'text-align' => 'left' .... );
// equivalent to //.classname1 .classname2 {color: #12AB00; text-aling: left;}
Add_css($css); ?php>
Thoughts, suggestions?
Mark Fredrickson E-Advocacy Manager Planned Parenthood Minnesota, North Dakota, South Dakota 1200 Lagoon Ave. Minneapolis, MN 55408 Ph: 612.821.6154 Fax: 612.825.3522 Email: mfredrickson@ppmns.org
Are you a member of the Action Network? http://www.ppaction.org/ppmsd/join.tcl
Hi Im wondering if anyone can help me with this. Im trying to remove the pipe characters from the primary links navigation. i realize that i could go into the core and change it there no problem. but im trying to customize a plugnplay type of theme that auto replaces the pipe characters with <br />'s since im using the primary links in a vertical navigation and want each link on a new line. Im thinking a simple little javascript, but i haven been able to find something for this exact purpose. does anyone know how to accomplish this? http://drupal.brandform.net
thanks -Isaac
At 3:42 PM -0800 26/12/05, Isaac Horton wrote:
Im trying to remove the pipe characters from the primary links navigation. i realize that i could go into the core and change it there no problem.
In 4.7 you can have your theme call theme('menu_links', $links) which will return the links in a <ul>. You can then apply styles to that as required.
In 4.6 it's a bit harder... you need to iterate over the $links array yourself and output the HTML you want. There are plenty of examples of this in contrib themes. Argeebee does this: http://cvs.drupal.org/viewcvs/drupal/contributions/themes/argeebee/page.tpl....
...Richard.