1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Creating a Page with No Theme

Creating a Page with No Theme

7 posts, 1 answered
  1. Jeff
    Jeff avatar
    124 posts
    Registered:
    05 Aug 2007
    28 Jul 2009
    Link to this post
    Hello,

    I currently have no need to use themes for my pages. MasterPages (templates) suffice. The problem is, I can't seem to not set a theme- it always defaults to "Blue with right sidebar."

    Here is how I'm creating the page:

                string strPageTitle = string.Format("ItsTime-{0}-{1:00}{2:00}-{3:00}-{4:00}-{5:00}"
                    DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, 
                    DateTime.Now.Minute, DateTime.Now.Second); 
     
                CmsManager cmsManager = new CmsManager(); 
     
                ICmsPage NewsPage = cmsManager.CreatePage(strPageTitle, new Guid("cced7579-2e2e-4939-9618-85cff81949d0")); 
     
                IStagedPage staged = NewsPage.Staged.CheckOut(); 
     
    // Default template- Default.master 
                Guid templateId = ((IPageTemplate)cmsManager.GetTemplates()[0]).ID; 
                staged.SetTemplate(templateId, null); 
     
    ... 
                staged.CheckIn(); 
     
                NewsPage = (ICmsPage)cmsManager.GetPage(NewsPage.ID, true); 
                NewsPage.Publish(); 

    For the SetTemplate Theme parameter, I've tried an empty string, I've tried "[No theme]" and I moved all of the themes out of App_Themes.

    Nothing works. It always wants to grab the "Blue with sidebar" theme.

    Any advice here?

    Thanks,
    Jeff
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    28 Jul 2009
    Link to this post
    just off the top of my head, you could leave that theme selected, but delete all of the css, images, and content files from the theme folder.

    you won't be able to not set a theme, but at least it won't actually theme your page...

    EDIT: correction, if you go into the Templates section of Pages (insted of sitemap) you can assign "No Theme" to the master template page

    hope this helps!
  3. Jeff
    Jeff avatar
    124 posts
    Registered:
    05 Aug 2007
    28 Jul 2009
    Link to this post
    Thanks for the quick reply SelArom.

    I considered stripping everything out of the theme and may end up doing that if a more elegant solution doesn't present itself.

    When I edit the page through the Sitefinity UI, the theme actually says "[Template Theme]" in the dropdown, though the HTML source still links the "Blue with Sidebar" css.

    Creating a page from scratch through the UI leaves it in the same state: [Template Theme] is the theme yet there are at least two css references to Blue with Sidebar.

    I appreciate the help.

    Thanks,
    Jeff
  4. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    28 Jul 2009
    Link to this post
    not sure if you saw my edit up there in my last post, but you can change the theme of a template to be no theme, that way all new pages (and any you set to template theme) will revert to no theme.

    let me know if that works!
  5. Jeff
    Jeff avatar
    124 posts
    Registered:
    05 Aug 2007
    28 Jul 2009
    Link to this post
    Thanks for that. We're getting closer (maybe).

    I set the default theme to [No Theme]. Now when the page comes up, I get:

    Theme '[No Theme]' cannot be found in the application or global theme directories.


    It didn't work, but at least I'm a bit wiser. I had never ventured into the Templates editor and didn't realize you could set a default template.

    Thanks again for your help.

    Jeff
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    29 Jul 2009
    Link to this post
    Hello Jeff,

    Internally in the code we select the first theme when you save the page. You can try creating a new theme - just create a folder without any images or styles. Then when you create your page choose newly created theme.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
    Answered
  7. Jeff
    Jeff avatar
    124 posts
    Registered:
    05 Aug 2007
    29 Jul 2009
    Link to this post
    That worked perfectly.

    I created an empty folder under App_Themes called "Dummy". Then I call SetTemplate, like so:

                staged.SetTemplate(templateId, "Dummy");

    The HTML in the resulting page no longer references theme style sheets.

    Thanks again for your help Ivan and SelArom.

    Jeff
Register for webinar
7 posts, 1 answered