variable issue

Permalink
Hi, I'm making a custom template for the auto-nav block for a site. It's pretty simple, based on the Header Nav template, but I need to add a uniques class name in the <a href..> tag, the class name should be the name of the page.

For instance, if the page was titled 'About Us', then the name of the page in the navigation would be 'about_us'. I want to be able to put htat class name in the <a> tag, so it would be something like <a class="about_us" href="/concrete5/about_us">About Us</a>.

I realize how to get the title; $ni->getName(), is there a simple function to get the filename name too?

Reason for the unique classes; graphical sprite based side menu, so if you have a better idea I'm all for it (other than hard coding, I need the active page indicated too).

hbartlett
 
jbx replied on at Permalink Reply
jbx
This should already be set in your template if you have based it on the original view. It usually comes from $ni->getURL(). This will give you the full link. You may need to do something like:
$path = explode('/',$pageLink);
$part = count($path) - 1;
echo $path[$part];
to get just the filename. (There may be an easier way to do that! Check $c - the collection object. May well contain it already).

By default, the standard template already gives you a class for the active link. Check out the if statement:
if ($c->getCollectionID() == $_c->getCollectionID()) {

hth

Jon