body IDs and classes

Discuss phpwcms here, please do not post support requests, bug reports, or feature requests! Non-phpwcms questions, discussion goes in General Chat!
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: body IDs and classes

Post by update »

pepe wrote:"das Gewehr in's Getreide"
...oder die Flinte in den Korn... :mrgreen:
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
User avatar
swisscheese
Posts: 138
Joined: Mon 19. Feb 2007, 16:37
Location: Solothurn, Schweiz

Re: body IDs and classes

Post by swisscheese »

Hi claus

Put this code in a frontend_render script:

Code: Select all

if(count($LEVEL_ID)) {
   foreach($LEVEL_ID as $val) $bodyclass .= $template_default['body']['class'].$val.' ';
   $content['all'] = '<div class="'.$bodyclass.'">'."\n".$content['all']."\n</div>\n";
}
Set the conf values:

Code: Select all

$template_default['body']['id'] = 'myid_';
$template_default['body']['class'] = 'myclass';
You will get a div wrapped around your whole content something like this: (where level id 10 is a sublevel of level id 2 which is a sublevel of home level id 0)

Code: Select all

<body id="myid_10" class="myclass_10> <!--this comes out of the box-->
<div class="myclass_0 myclass_2 myclass_10 "> <!-- this comes from frontend_render-->
...content...
</div>
</body>
You are able to set css stuff for a specific level with all the sublevels (eg .myclass_2 p {background:red;})

have fun, swisscheese
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: body IDs and classes

Post by update »

Thank you :)
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
User avatar
Jensensen
Posts: 3000
Joined: Tue 17. Oct 2006, 21:11
Location: auf der mlauer

Re: body IDs and classes

Post by Jensensen »

Hi swisscheese,

[btw.: i like it very well]

as you mentioned above, this does not affect --> body tag.
but might be a good idea, anyway. :wink:

So, in addition for this approach CSS can / could / would be:
body#myid_10 div.myclass_0.myclass_2.myclass_10 { styles: here; }
and so on...

or even:
body#myid_10.myclass_10 div.myclass_0.myclass_2.myclass_10 { styles: here; }


for those, who work it this way.
{so_much} | Knick-Knack. | GitHub
Umlaute im URL sind meistens immer Kacke.
User avatar
swisscheese
Posts: 138
Joined: Mon 19. Feb 2007, 16:37
Location: Solothurn, Schweiz

Re: body IDs and classes

Post by swisscheese »

Jensensen wrote: as you mentioned above, this does not affect --> body tag.
yep. couldn't find a way to inject body tag with frontend_render. So you'll get this div tag, but this shouldn't be a problem...
body#myid_10.myclass_10 div.myclass_0.myclass_2.myclass_10 { styles: here; }
nope! so you will only affect level id 10 whithout any sublevel (and here #myid_10 {styles: here} would be enough code...) :wink:
if you want affect a whole tree under a certain level, you would put in your css .myclass_2 {styles: here;} This way, the level id 2 AND ALL levels, sublevels, subsublevels... will be affected

have fun, swisscheese
User avatar
Jensensen
Posts: 3000
Joined: Tue 17. Oct 2006, 21:11
Location: auf der mlauer

Re: body IDs and classes

Post by Jensensen »

x
{so_much} | Knick-Knack. | GitHub
Umlaute im URL sind meistens immer Kacke.
Post Reply