App_Theme

Store UI, layout, design, look and feel; Discussion on the customer facing pages of your online store. Cascading Style Sheets, Themes, Scriptlets, NVelocity and the components in the ConLib directory.
Post Reply
User avatar
Tomgard
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 108
Joined: Sun Jul 20, 2008 1:00 pm

App_Theme

Post by Tomgard » Sat Aug 30, 2008 7:13 pm

Is it possible to tie an application theme to a particular user or user group?

I have a lot of B2B customers and I would like use their logo/color scheme during their shopping session.
Bryan Bundgaard
AC7 User http://www.SchoolSupplyStore.com

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: App_Theme

Post by mazhar » Mon Sep 01, 2008 5:28 am

Well ASP.NET provides ways to change the theme through code. For this you have to set the Page.Theme property in the Page_PreInIt event handler like below

Code: Select all

protected void Page_PreInit(object sender, EventArgs e)
    {
        Page.Theme = "theme name";
    }
You can give a try in your pages by first checking the user group or any other criteria for which you want to change the theme and then set theme accordingly.

bemara579
Lieutenant (LT)
Lieutenant (LT)
Posts: 63
Joined: Thu Feb 19, 2009 6:15 pm

Re: App_Theme

Post by bemara579 » Tue Apr 28, 2009 10:19 pm

You can also put this in your Global.asax (notice how I am using the affiliate mobile number field to store the theme to avoid messing with the database schema):

Code: Select all

    
    // this event is executed for every page request
    // and is run before the PreInit event. Therefore we
    // can use it to set the theme and master for every page
    protected void Application_PreRequestHandlerExecute(object sender, System.EventArgs e)
    {
        // cast the current handler to a page object
        Page page = HttpContext.Current.Handler as Page;

        if (page != null)
        {
            // add an event handler for the PreInit event (the master page needs to be set there)
            page.PreInit += new EventHandler(Custom_PreInit);
        }
    }

    void Custom_PreInit(object sender, EventArgs e)
    {
        // cast the current handler to a page object
        Page page = HttpContext.Current.Handler as Page;

        if (page != null)
        {
            if (!Request.FilePath.StartsWith("/Admin/") && 
                Token.Instance.User.Affiliate != null && Token.Instance.User.Affiliate.MobileNumber != String.Empty)
                page.Theme = Token.Instance.User.Affiliate.MobileNumber;
        }
    }

Post Reply