How to get slug name of current BE generated "page" in code?

Topics: Themes
Nov 17, 2008 at 10:25 PM
Edited Nov 18, 2008 at 12:38 PM
New to BE but very impressed so far. Was looking at GraffitiCMS and disappointed and then found this!

I have it running locally and have started with the illacrimo theme. It is one of the few themes which highlights the currently selected main menu option (appears a selected tab in illacrimo). However, Al Nyveldt's site appears to be the only one I have found where this highlight is actually working. By default, the Home selection stays highlighted regardless of which meny option is chosen.

The original menu code in this theme uses a hard-coded class="on" for the first menu option. It looks like the following the first home option is always highlighted even when other options are clicked:

<li><a class="on" href="<%=Utils.AbsoluteWebRoot %>" rel="home"><span><%=Resources.labels.home%></span></a></li>

To resolve this, I borrowed code from another theme that builds the menu options using standard .NET hyperlink controls and thus was able to control the class setting programmatically. The main menu links in the site.master now look like this:

<li><asp:HyperLink id="menulink_home" runat="server" NavigateURL="~/default.aspx"><span><%=Resources.labels.home%></span></asp:HyperLink></li>
I am simply using Request.Url.ToString() to perform a substring compare against what the pages are named such as default.aspx (home) or archive.aspx (archive). However, for any "pages" that I create in BE such as "my-personal-page" will show up with the physical XML file name that holds the page properties which is a GUID like value, rather than the slug name such as "my-personal-page". This forces me to compare to the GUID string rather than the slug name so the code is not very readable.

My question is how can I access the slug name of "page" created in BE when it is the current page being shown? I am confident there is way to do this and was hoping someone with some experience could show me how. Any tips on better approaches to control the currently selected menu option is also appreciated as that is my primary need here.