How to add a class to body tag
How to add a class to body tag
I'm not sure if this is the correct forum. Please excuse me if it isn't.
The way our CMS was set up was with 5 different templates. The only difference between the templates is that the body tag has a different background image for each template in a css class.
Is there a way to do this without having a separate template for each instance the background image changes?
Thank you very much,
Camille
The way our CMS was set up was with 5 different templates. The only difference between the templates is that the body tag has a different background image for each template in a css class.
Is there a way to do this without having a separate template for each instance the background image changes?
Thank you very much,
Camille
Re: How to add a class to body tag
Remove the background-image from the stylesheet and use inline styles instead. Rename the images to match the page-alias that you are on or other such scheme.
Template:
Change the page, you get a different picture. If you share the same picture for several pages, you can make a one-liner content box where the content editor can type in the name of the image they want. If they don't enter one in, your template logic would use a default image.
Template:
Code: Select all
</__body style="background-image:url({$page_alias}.jpg);">
Re: How to add a class to body tag
Thank you! I will work on that tonight. How do I create a one-liner content box though?
Thanks!
Thanks!
Re: How to add a class to body tag
The usage is documented under Extensions -> Tags -> Content
In your template:
When you edit your page, you will have an entry called "Background Image".. The value will be in a Smarty variable called $background_image
I would put this content block before the <head>. This section gets processed first, then the </__body>, then the <head>. Then put:
(adjust the path above to fit the location of your images)
In your template:
Code: Select all
{content block="background" label="Background Image" oneline="true" assign="background_image"}
I would put this content block before the <head>. This section gets processed first, then the </__body>, then the <head>. Then put:
Code: Select all
</__body style="background-image:url(uploads/images/{$background_image});">
Re: How to add a class to body tag
This is great help. I will do that tonight and see how it works out.
Re: How to add a class to body tag
Hi, this is an easy solution, and works well.
I still need to be able to add a css class to the body tag though. The background images that are being used have css position properties. Is that possible to do?
Thanks!
Camille
I still need to be able to add a css class to the body tag though. The background images that are being used have css position properties. Is that possible to do?
Thanks!
Camille
Re: How to add a class to body tag
Code: Select all
</__body class="{$page_alias}">
Code: Select all
body.my-page-alias {
my: style;
}
Re: How to add a class to body tag
I wish it could be that simple. The site has at least 100 pages, each with different page aliases.
Re: How to add a class to body tag
Hi Camilep,
This is the UDT i sometimes use if i want to have specific css rules for groups of pages or individual pages:
http://wiki.cmsmadesimple.org/index.php ... page_class
Just try it and you'll be pleasantly surprised!!
Greetings,
Manuel
This is the UDT i sometimes use if i want to have specific css rules for groups of pages or individual pages:
http://wiki.cmsmadesimple.org/index.php ... page_class
Just try it and you'll be pleasantly surprised!!
Greetings,
Manuel