Sitefinity ASP.NET CMS - Content Management System

Support Forum Thread

Home >  Support >  Forums home > Sitefinity 3.x > Themes, Designs, Templates > front end - change theme via drop down

Reply
Quade, 5/1/2008 8:04:08 AM
is it possible to have a drop down on the front end site listing all the themes

and whatever theme is selected, the site will use that design.
 
the theme would have to be remember in a cookie for subsequent visits

thanks

Reply
, 5/7/2008 6:20:38 AM
Hi Quade,

You can take a look at the implementation of System.Web.UI.Page.PerformPreInit method:

private void PerformPreInit()  
{  
    this.OnPreInit(EventArgs.Empty);  
    this.InitializeThemes();  
    this.ApplyMasterPage();  
    this._preInitWorkComplete = true;  
}  
 

To programmatically set themes, please follow these steps:
  1. Create a new class in the  App_Code folder that inherits from Telerik.Cms.Web.InternalPage and override OnPreInit method. Enter your logic in this method (store information in cookie etc.).
    public class CustomPage : Telerik.Cms.Web.InternalPage  
    {  
        protected override void OnPreInit(EventArgs e)  
        {  
            base.OnPreInit(e);  
            this.Theme = "MyTheme";  
        }  
    }  
     
  2. Replace the declaration of InternalPage class with the name of your newly created class in the following file ~/Sitefinity/cmsentrypoint.aspx. The file should look like this:
    <%@ Page Language="C#" MasterPageFile="~/App_Master/Dummy.master" Inherits="CustomPage" %> 
     
In this case we have set MyTheme dynamically as a theme of our site. Then you should create the dropdown box with your theme names as values.

Sincerely yours,
Georgi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center

Reply
eighty8keyZ, 6/12/2008 10:51:04 AM
This solution sounds great but which "App_Code" folder are you referring to?  I can't find an "App_Code" folder in my site directory.
Reply
, 6/13/2008 2:51:37 AM
Hi Jessica Fonseca,

You need to create one for the given project. This folder is generally used for adding source code to the project.

Best wishes,
Sonya
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center