More in this section

Forums / Developing with Sitefinity / GetCurrentTheme() returns empty

GetCurrentTheme() returns empty

2 posts, 0 answered
  1. Jeff
    Jeff avatar
    118 posts
    Registered:
    08 Jul 2011
    15 Mar 2012
    Link to this post
    I'm using the following code to retrieve the current theme but am getting an empty string instead. I have the frontend theme set in settings. Am I missing something else?
    01.public static string GetCurrentTheme()
    02.    {
    03.        Guid currentPageId = GetCurrentPageId();
    04.        PageNode pn = GetPageNode(currentPageId);
    05. 
    06.        return GetPageTheme(pn);
    07.    }
    08. 
    09.    public static Guid GetCurrentPageId()
    10.    {
    11.        Guid pageId;
    12.        PageSiteNode psn = SiteMapBase.GetActualCurrentNode();
    13. 
    14.        if (psn == null)
    15.        {
    16.            PagesConfig pagesConfig = Config.Get<PagesConfig>();
    17.            pageId = pagesConfig.HomePageId;
    18.        }
    19.        else
    20.        {
    21.            pageId = psn.Id;
    22.        }
    23. 
    24.        return pageId;
    25.    }
    26. 
    27.    public static PageNode GetPageNode(Guid pageId)
    28.    {
    29.        var pf = App.WorkWith().Page(pageId);
    30.        return pf.Get();
    31.    }
    32.     
    33.    public static string GetPageTheme(PageNode pn)
    34.    {
    35.        return (pn.Page.Template != null) ? pn.Page.Template.Theme : "";
    36.    }

  2. Jeff
    Jeff avatar
    118 posts
    Registered:
    08 Jul 2011
    18 Mar 2012
    Link to this post
    Bump
2 posts, 0 answered