Auto-Nav Template

Permalink
Hi I have an auto nav template which I have built which is styled to my liking but I cannot figure out where in my view.php to state the current class for my LI can any one help?

CSS:...
#nav {
    margin: 0;
    padding: 7px 6px 0;
    line-height: 100%;
    border-radius: 2em;
    -webkit-border-radius: 2em;
    -moz-border-radius: 2em;
    -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
    -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
    background: #8b8b8b; /* for non-css3 browsers */
    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#a9a9a9', endColorstr='#7a7a7a'); /* for IE */
    background: -webkit-gradient(linear, left top, left bottom, from(#a9a9a9), to(#7a7a7a)); /* for webkit browsers */
    background: -moz-linear-gradient(top,  #a9a9a9,  #7a7a7a); /* for firefox 3.6+ */
    border: solid 1px #6d6d6d;
}


PHP: ...
<?php
   defined('C5_EXECUTE') or die(_("Access Denied."));
   $aBlocks = $controller->generateNav();
   global $c;
   if ($c->isEditMode()) {
      echo("
<ul id=\"nav\">");
   }
   else {
      echo("
<ul id=\"nav\">");
   }
   $nh = Loader::helper('navigation');
   foreach($aBlocks as $ni) {
      $_c = $ni->getCollectionObject();

darwinje
 
braincramp replied on at Permalink Reply
braincramp
Why do you need a class for the li? Can't you just target the li from the id?
#nav li {
styling…
}

Or am I missing something?
darwinje replied on at Permalink Reply
darwinje
Thanks for the reply

I have a current class for the LI which highlights the link to show if its the current page or not .current. and thats what I am trying to work out in the menu, also my sub <ul>'s and <li>'s aren't working either.

I am a newb to this and I am pulling my hair out! ;)

Thanks again

Justin
braincramp replied on at Permalink Reply
braincramp
I believe the autonav already uses a class for the current page .nav-selected or .nav-page-selected or are you trying to do something else?
cssninja replied on at Permalink Reply
cssninja
Add after
if (!$_c->getCollectionAttributeValue('exclude_nav')) {

if ($ni->isActive($c) || strpos($c->getCollectionPath(), $_c->getCollectionPath()) === 0) {
            $navSelected='current';
         } else {
            $navSelected = '';
         }


And instead of
echo '
<li><a href="'.$pageLink.'">' . $ni->getName();

echo '<li class="'.$navSelected.' '.$isFirstClass.'">';
         if ($c->getCollectionID() == $_c->getCollectionID()) { 
            echo('<a class="current" href="' . $pageLink . '">' . $ni->getName() . '</a>');
         } else {
            echo('<a href="' . $pageLink . '">' . $ni->getName() . '</a>');
         }   
         echo('</li>');
darwinje replied on at Permalink Reply
darwinje
Thanks Ninja!

is this right?

<?php
   defined('C5_EXECUTE') or die(_("Access Denied."));
   $aBlocks = $controller->generateNav();
   global $c;
   if ($c->isEditMode()) {
      echo("
<ul id=\"nav\">");
   }
   else {
      echo("
<ul id=\"nav\">");
   }
   $nh = Loader::helper('navigation');
   foreach($aBlocks as $ni) {
      $_c = $ni->getCollectionObject();
cssninja replied on at Permalink Reply
cssninja
I think so, checking out if it works?