Jump to content

[SOLVED] Different background for each category


Recommended Posts

I was thinking:

create 3 different background with 3 different name as the category name, and using CSS to load backgrounds depending the category that a user visit.

How to print the name of a category that a user visit in the header.tpl file?

Other possibilities?

Link to comment
Share on other sites

See the first three code blocks in my post here.
rocky... great!

Some things:

Category A -> Background 1
Category B -> Background 2

But how to see Background 3 when a user visit index, sitemap or others page that are not gategory?

Category A and Category B have subcategory, for now I write in the CSS file all the sub-category ID to match the background of the main category, it is possible to do so automatically? Because if I create an other sub-category of Category A, I must modify global.css file to connect this sub-category to Background 1.
Link to comment
Share on other sites

Well... I use in header.tpl the following code

<body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if}{if $smarty.get.id_category} class="cat{$smarty.get.id_category}"{elseif $default_category} class="cat{$default_category}"{/if}>



It is OK for
Category A -> Background 1
Category B -> Background 2
And all the sub-category of Category A and Category B because I write all in the CSS file.

But how to see Background 3 for all page (like index, sitemap, contact) of the site excluded Category A, Category B and sub-category? I think that I need an other "elseif" in the code but I don't know how.

Link to comment
Share on other sites

in your global.css:
"body.cat2", "body.cat3", "body.cat4" etc. will be backgound for categories, "body" will contain backgound image for all other pages (index, cms etc.)

example:

body {
background-color: #000000;
font-size: 11px;
font-family: Arial, Helvetica, Sans-Serif;
color: #ffffff;
text-align:center;
background-attachment: fixed;
background-image: url(../img/background-default.jpg);
background-repeat: no-repeat;
background-position: center top;
}
body.cat1 {
background-color: #000000; background-image: url(../img/background-cat1.jpg)
}
body.cat2 {
background-color: #000000; background-image: url(../img/background-cat2.jpg)
}

... etc.

  • Like 1
Link to comment
Share on other sites

in your global.css:
"body.cat2", "body.cat3", "body.cat4" etc. will be backgound for categories, "body" will contain backgound image for all other pages (index, cms etc.)

example:

body {
background-color: #000000;
font-size: 11px;
font-family: Arial, Helvetica, Sans-Serif;
color: #ffffff;
text-align:center;
background-attachment: fixed;
background-image: url(../img/background-default.jpg);
background-repeat: no-repeat;
background-position: center top;
}
body.cat1 {
background-color: #000000; background-image: url(../img/background-cat1.jpg)
}
body.cat2 {
background-color: #000000; background-image: url(../img/background-cat2.jpg)
}

... etc.
Perfect, thanks!
Link to comment
Share on other sites

  • 1 year later...

Hi!

 

I would like to do the same, but in my case, I need to modify the name of an id, instead of adding a class.

 

In your code, if the condition verifies, you add 'classid'.

 

But a have a div with the id 'wrapper3', that I would like to show a different background image, depending on the category.

 

Does anybody know how to adapt the code for that?

 

Thanks a lot in advance! :)

Link to comment
Share on other sites

  • 7 years later...

Hi - I already have this implemented for Prestashop 1.6. Works great.

Howwever am thinking of changing to Prestashop 1.7 and coding is completely different - does anyone have an update on how to achieve this with Prestashop 1.7?

Thanks

Baz

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...