HarryCom Posted January 4, 2011 Share Posted January 4, 2011 Hi!For my PrestaShop website I want to see a different background for each category that a user visit. What to do?So:Category A -> Background 1Category B -> Background 2Category C -> Background 3 Link to comment Share on other sites More sharing options...
HarryCom Posted January 4, 2011 Author Share Posted January 4, 2011 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 More sharing options...
HarryCom Posted January 4, 2011 Author Share Posted January 4, 2011 U P ! Link to comment Share on other sites More sharing options...
rocky Posted January 5, 2011 Share Posted January 5, 2011 See the first three code blocks in my post here. Link to comment Share on other sites More sharing options...
HarryCom Posted January 5, 2011 Author Share Posted January 5, 2011 See the first three code blocks in my post here.rocky... great!Some things:Category A -> Background 1Category B -> Background 2But 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 More sharing options...
HarryCom Posted January 6, 2011 Author Share Posted January 6, 2011 rocky, help please! Link to comment Share on other sites More sharing options...
rocky Posted January 6, 2011 Share Posted January 6, 2011 See this topic. Link to comment Share on other sites More sharing options...
HarryCom Posted January 6, 2011 Author Share Posted January 6, 2011 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 forCategory A -> Background 1Category B -> Background 2And 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 More sharing options...
Sem Tam Posted January 6, 2011 Share Posted January 6, 2011 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. 1 Link to comment Share on other sites More sharing options...
HarryCom Posted January 7, 2011 Author Share Posted January 7, 2011 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 More sharing options...
manuelraigada Posted January 24, 2012 Share Posted January 24, 2012 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 More sharing options...
ukbaz Posted May 17, 2019 Share Posted May 17, 2019 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now