开发者

Add CMS link to nav - Force Active State

开发者 https://www.devze.com 2023-02-16 23:24 出处:网络
so i added this: <li class=\"level0 nav-1 parent\"><a href=\"<?php echo $this->getUrl(\'blog\')?>\"><span><?php echo $this->__(\'Blog\') ?></span></a>&

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 i开发者_Go百科f ($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)


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

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


Thanks for the tip

I ended up using

getRequest()->getRouteName

many many thanks!

0

精彩评论

暂无评论...
验证码 换一张
取 消