Add CMS link to nav – Force Active State

so i added this:

       <li class="level0 nav-1 parent"><a href="<?php echo $this->getUrl('blog')?>"><span><?php echo $this->__('Blog') ?></span></a></li> 

and also tried this:

<li <?php if ($this->getRequest()->getAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS) == 'blog') { echo 'class="active"'; } else { echo 'class="blog"'; } ?>><a href="<?php echo $this->getUrl('blog')?>"><span><?php echo $this->__('Blog') ?></span></a></li>

in top.phtml. the link appears as expected.

but it does not display the active state of the button (the rectangle around the text) like the native links do.

here is the page:

http://pro-tools-training.com/new-magento2/index.php/

(click all the links in the nav and you’ll see they all hold the active state except Blog)

2 thoughts on “Add CMS link to nav – Force Active State”

  1. You may be having PHP string comparison issues. Try using strcmp.

    Also, try getRequest()->getOriginalPathInfo() instead of getAlias()

Leave a Reply

Your email address will not be published. Required fields are marked *