How can I add an ID to the body tag per page?

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Locked
stinhambo

How can I add an ID to the body tag per page?

Post by stinhambo »

I use custom CSS rules to highlight a menu depending on which page I'm on based on the BODY ID and LI CLASS.

Is there a way of defining a body id and class via the CMS or do I have to create a seperate template for each page to achieve this?
tsw
Power Poster
Power Poster
Posts: 1408
Joined: Tue Dec 13, 2005 10:50 pm

Re: How can I add an ID to the body tag per page?

Post by tsw »

in your template

Code: Select all

</__body id="page{$page_id}">
hope this helps

btw, you can use {get_template_vars} to check what variables are usable on a page...
stinhambo

Re: How can I add an ID to the body tag per page?

Post by stinhambo »

I used -



in the end.

It seems to work at the moment for me :)
tsw
Power Poster
Power Poster
Posts: 1408
Joined: Tue Dec 13, 2005 10:50 pm

Re: How can I add an ID to the body tag per page?

Post by tsw »

works also, but isnt automagick ;)
stinhambo

Re: How can I add an ID to the body tag per page?

Post by stinhambo »

What do I do with {get_template_vars}?

Yes I see what the previous hint does. I might have to go with it as I need to insert an ID and a class into the Body tag.
tsw
Power Poster
Power Poster
Posts: 1408
Joined: Tue Dec 13, 2005 10:50 pm

Re: How can I add an ID to the body tag per page?

Post by tsw »

with {get_template_vars} you can check what variables are present in that page.

you can use all those variables as you like just like {$sitename} and so on
Locked

Return to “Layout and Design (CSS & HTML)”