geekmas #3 cheap n nasty path css trick

3 December 2007 mortendk

The easiest way ever to tell your stylesheet where you are on you drupal website -with a little help from zen.
Sorry that im 1 day behind on my geekmas thingie, my GF gave me Guitar HeroIII yesterday as a "theres 6 days til you gonna 34, so you better have it now" .. So I have been Rocking all night \m/ Yeaaah!

One of the things that made me loose some of my hair in drupal is to create an easy way to tell where in a site you are.
So if you look at page created with the view or panels module you can easily tell the stylesheet to "hide this and make that column 200px..." etc
-I know the css puritist, are getting the knifes and are ready to attack - cause display:none is evil, bad & yadi yadi yadi... but dammit it gets the job done! (Ush i know im gonna get my ass kickes for this...)

Well the cheap n nasty trick here is easy & even forces us frontend geeks to look at the args() function

_phptemplate_variables to the rescue!

If you like me uses elements from the zen theme (template.php) this is gonna be really easy, but just so we all are on the same page.. what i do is just adding the path to the $body_classes, so I can add specific styles to a element on a given page, say body.news h2.title

Inside the template.php file in the _phptemplate_variables add this to the page case:

#000000">#0000BB"><?php
   
#007700">case #DD0000">'page'#007700">:

    
#FF8000">//paths -where are we...
      
#0000BB">$args #007700">= #0000BB">arg#007700">(#DD0000">'0'#007700">);
      
#0000BB">$body_classes#007700">[] = #DD0000">'path-'#007700">. #0000BB">zen_id_safe#007700">(#0000BB">$args#007700">);   
#0000BB">?>

Offcourse as the king of "self-promoting-bragging-loudmouthness-arrogance" - and denmark [tm] I have cast aside the zens css (well some of it), and templates and build my own css "framework" on top of it - yup i dont like it when its called .break but clearFix ;) .. and well i didnt wanna change the way i have been writing my css the last couple of years - yup im an oldy grumpy man

vWZlsuiDVkx

qzxRar hmL40Mdg41UrgAs6a

barner 16 September, 2008 - 04:42
The content of this field is kept private and will not be shown publicly.
@codingdesigner @chriscoyier off course it wins its powered by #teamsass ;) 35 min 23 sec ago
3,785

DrupalCon Denver 2012 - I am a Speaker!

good Stüff

Mothership - a clean up the crap "theme"

Miro - a open atrium theme:
more info & comments

freya rocks

the progress for my premature daughter can be folllowed here:
Freya Rocks
sorry its in danish

Give some Love to the development of the mothership

Flattr this

User login

Recent comments

give some luv

drupal member ...

geek royale