CSS / Theme Selector

Posted by Community Admin on 03-Aug-2018 15:39

CSS / Theme Selector

All Replies

Posted by Community Admin on 31-Aug-2010 00:00

How would I go about creating a control for users changing the theme of a site on the frontend, similar to the theme button when editing a page?

Posted by Community Admin on 01-Sep-2010 00:00

Hello Kristian,

Here is a sample code that illustrates how to change the Theme at runtime

var manager = PageManager.GetManager();
SiteMapNode currentNode = SiteMapBase.GetCurrentProvider().CurrentNode;
Guid pageId = ((PageSiteNode)currentNode).PageId;
var draft = manager.EditPage(pageId, true);
draft.Theme = "test2";
manager.PublishPageDraft(draft.Id, true);
manager.SaveChanges();
SiteMapBase.Cache.Flush();
Response.Redirect(currentNode.Url);


Best wishes,
Ivan Dimitrov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 01-Sep-2010 00:00

Thank you,


would there be a way to propagate this change to all pages? or at least apply this to the template so all pages using that template would reflect the new theme?

Posted by Community Admin on 01-Sep-2010 00:00

Hello Kristian,

Here is a sample code that illustrates how to change the template theme, but there are issues with setting this at runtime and you have to edit the page and then save it.

var manager = PageManager.GetManager();
 var templateID = manager.GetTemplates().Where(t => t.Title == "Copy of Default").SingleOrDefault().Id;
 var editTemplate = manager.EditTemplate(templateID, true);
 editTemplate.Theme = "test2";
 manager.SaveTemplateDraft(editTemplate.Id);
 manager.PublishTemplateDraft(editTemplate.Id);
 manager.SaveChanges();
 SiteMapBase.Cache.Flush();

Regards,
Ivan Dimitrov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 01-Sep-2010 00:00

I'm not sure if I have this working correctly. I set both my template and page to use no theme on the backend. Then I click on the button on my page to change the template theme. I check the template under page templates and i see the new theme is reflected in the editor. I click publish on the theme and then refresh the page i wanted the theme to change. but it still appears as no theme.


Will this be resolved after the beta? Would this be the best way of changing the overall theme of the site?

Posted by Community Admin on 01-Sep-2010 00:00

Hi Kristian,

Editing the page should apply the theme on it properly. As I wrote there are issues with this process when you are working programatically and we have logged this issue for fixing.

Greetings,
Ivan Dimitrov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 24-Nov-2010 00:00

finally got back around to this but receive a 403 when trying to retrieve the css

GET main.css
403 Forbidden
localhost:26688
1.2 KB

HtmlLink link = new HtmlLink();
        link.Href =
            "~/App_Data/Sitefinity/WebSiteTemplates/UserDefined/App_Themes/Red/Global/main.css";
        link.Attributes.Add(HtmlTextWriterAttribute.Rel.ToString(), "stylesheet");
        Page.Header.Controls.Add(link);

Posted by Community Admin on 24-Nov-2010 00:00

Hello Kristian,

It looks like you have the same problem as this one discussed here.

Sincerely yours,
Ivan Dimitrov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 24-Nov-2010 00:00

Thanks for the help, i solved it by just starting the path from ~/Sitefinity instead of ~/App_Data

Posted by Community Admin on 24-Nov-2010 00:00

How come certain widgets do not work the same with a custom theme, for example the lightbox option for an image gallery?

Posted by Community Admin on 24-Nov-2010 00:00

Hello Kristian,

You have something in your theme/template that breaks the widget. Is there any information in the browser console - js error, css loading issues etc.

Kind regards,
Ivan Dimitrov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed