Hi. I'm needing to set a dynamic body ID in my Page template based on the page loaded, so that different CSS layouts can be used.
Would anyone be able to give any advice on how to do this?
I had read that using "> would do the trick, but that seems to set replace the BlogTemplateSetID with mt-blog... could I use some form of tagging or categories?
Thanks,
Barella
Reported on Movable Type 4.2
Depends on the template set you are using really, you could easily add your own var to make life easy.
just add:
to your header template in the id section of the body tag (if it includes the body tag)
Then when you call that header template use this:
Thanks Richard for your help.
It seems to be working, but I'm struggling to work out the final piece.
I've added
to the Header 'Template Module' I've created, and
in the Page 'Archive Template' - is this correct? Or should I be creating new Index templates for each body ID I require?
Thanks,
Barella
replace "my-body-id" with whatever you want the ID to be! If it's going to be based on the MTPageID then you may have to chuck it into a var before you put it in the Include tag.
Where are these custom IDs coming from? i.e. how do you decide which page has what id?
Again thanks,
I have about six different ids I'm needing to use, which are based on the grouping of pages within my site. I;m still struggling to understand how this could be passed in as a variable... possibly through tagging the pages and passing the tag as the id? Is that feasible?
Yes, that's a good idea, would break if you added more than one tag to a page tho!
You could organize into folders and use the folder basename to set the id of the body.
If you're using Pro, you could add a custom field to select the id required, then load that back into the header var.
Or this plugin may be of use:
http://plugins.movabletype.org/page-layout/
(not tired it, but seems to do similar to what you are after)