Detect Homepage in BE

Topics: Business Logic Layer, Themes
Jan 20, 2014 at 1:56 PM
When you set a blog page as the homepage then the homepage URL becomes the page URL rather than default and likewise for the sitemap, the page becomes the root node.
The problem is, how can you tell at theme level from code if you are in the home page or actually in the page section? Normally you would inspect the URL to determine your location.

For example, for a navigation menu I want to highlight home when in the home section, but I also want to highlight the page section if viewing that page from the page section. How can I tell which one is which if the URL is the same?

In core UrlRewrite.cs there is this method.
 if (Utils.IsCurrentRequestForHomepage)
                var front = Page.GetFrontPage();
                if (front != null)
                    url = front.RelativeLink.ToUpperInvariant();                    
I could add a parameter to the rewritten url(not tested), say setAsFront=true and could then distinguish between a page front and the same page when not front, but I'd really be wanting to do this without modifying the core.

Anybody any ideas?
Jan 20, 2014 at 3:29 PM
Can't see the woods for the trees... RawUrl