Change theme based on category

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 years ago
Hi, I could have sworn I saw a topic about this once before and never could find it again.  What I want to be able to do is have the "theme" (actually just a few CSS changes like the back ground image) change based on the category the user is viewing.  For example, use is looking at the Widget's A category the background has a big letter A and everything is pink and red, but if they click to Widget's B category there is a big letter B in the background and everything is green and purple.
14 years ago
We did originally discuss this when nested master pages were first implemented.

The idea would be that you could perform master page mappings for different categories. Unfortunately this feature was not implemented.

To do this you would need add some new functionality.

1. Store master page names and paths in database
2. Store master page <> entity mappings in database
3. Override page OnPreInit event in BaseNopPage and add something like (obviously you need to create these classes):

MasterPageMappingCollection masterPageMappingCollection = UIManager.GetMasterPageMappings(this.CategoryID);
if (masterPageMappingCollection.Count > 0)
this.MasterPageFile = masterPageMappingCollection[0].Path;
else
this.MasterPageFile = UIManager.GetDefaultCategoryMasterPage.Path;

Hope this helps,
Ben
14 years ago
In Root.Master I changed to this
<div id="MasterWrapperPage" class="master-wrapper-page" runat="server">

I am using this code to change the background image of that div in a "Categories" Template in the Page_Load event by adding

HtmlGenericControl masterwrapperpage = (HtmlGenericControl)this.Page.Master.Master.FindControl("masterwrapperpage");
                
            switch (CategoryID)
            {
                case 1:
                    masterwrapperpage.Attributes.Add("style", "background-image:url('../back.jpg')");
                    break;
                
                default:
                    masterwrapperpage.Attributes.Add("style", "background-image:url('../villa.jpg')");
                    break;
            }

As you can tell the categoryID's have to be hard coded (not slick but real simple)

The Master.Master is because of the nested masters meaning OneColum.Master -> Root.Master because thats where the div is that we want to change the background of.

Hope this makes sense.

M
13 years ago
Hello. Could you explain to me in detail how to change theme based on category? I've read something on the nopcommerce site but i didn't understand anything :( Thank you.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.