Change page background for individual pages

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"
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Change page background for individual pages

Post by Dr.CSS »

I use it all the time as a class for body...



Then in css...

.pagealias #header {image call and other styles}

Or I use it on the very first div like pagewrapper...
simon.romin
Forum Members
Forum Members
Posts: 65
Joined: Tue Jul 13, 2010 9:31 am

Re: Change page background for individual pages

Post by simon.romin »

Hi!

Thanks for all your very helpful feedback on this! Hopefully somebody else searching will find this thread useful too.

But I have a similar request:

How can I change my header background image for a particular category?

This is quite common across many websites. The only example I can find at this present moment is:

http://www.hannsg.com/EU/EN/Products/LC ... ommon.aspx

Can you see what I mean?

Looking forward to any help!

Simon
simon.romin
Forum Members
Forum Members
Posts: 65
Joined: Tue Jul 13, 2010 9:31 am

Re: Change page background for individual pages

Post by simon.romin »

Hi guys,

Any thoughts on how to change the category background?

Cheers,

Simon
curlypinky
Forum Members
Forum Members
Posts: 109
Joined: Thu Sep 04, 2008 3:49 am

Re: Change page background for individual pages

Post by curlypinky »

Same idea as using css for individual pages but instead of getting the page_alias you want to get the root or parent alias. Depending on your setup (so if you have cat1 is 2.0, and cat 2 is 3.0 etc you'd be fine with root alias. But if your categories are deeper, lets say 2.1 and 2.2 are the categories and the 3rd level is the children, you'd want to get just the patent alias so you'd end up with the alias of 2.1 when you are on page 2.1.1. CalGuy's SimpleSmarty module is awesome for this (CGSimpleSmarty http://dev.cmsmadesimple.org/projects/cgsimplesmarty).
# get_parent_alias([$alias],[$assign])

Returns the alias of the specified pages parent. Returns an empty string if there is no parent.

Arguments:

    * [$alias] - (optional) The page alias to find the parent of. If no value is specified, the current page is used.
    * [$assign] - (optional) The name of a variable to assign the results to.


Example:

The parent page alias is {$cgsimple->get_parent_alias()}


# get_root_alias([$alias][,$assign])

Returns the alias of the specified pages root parent. Returns an empty string if there is no root parent.

Arguments:

    * [$alias] - (optional) The page alias to find the root parent of. If no value is specified, the current page is used.
    * [$assign] - (optional) The name of a variable to assign the results to.


Example:

The root parent page alias is {$cgsimple->get_root_alias()}
So just make sure your template is assigning a body class for the parent or root:

get_root_alias()}' id='{$page_alias}'>

And your css has the call for the appropriate header image in there ala:

body.rootalias1 #headerWrapper {background...}
body.rootalias2 #headerWrapper {background...}

Alane
simon.romin
Forum Members
Forum Members
Posts: 65
Joined: Tue Jul 13, 2010 9:31 am

Re: Change page background for individual pages

Post by simon.romin »

Hi,

Thanks for the very useful reply!

Is it possible to do this without using CGSimpleSmarty?

Thanks

Simon
curlypinky
Forum Members
Forum Members
Posts: 109
Joined: Thu Sep 04, 2008 3:49 am

Re: Change page background for individual pages

Post by curlypinky »

That I don't know, I would assume it is possible... but I don't think CalGuy would have gone to the trouble of creating CGSimpleSmarty with such functions if it could be done easily without it.
Alane
Post Reply

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