将 CMS 链接添加到导航 - 强制活动状态
所以我添加了这个:
<li class="level0 nav-1 parent"><a href="<?php echo $this->getUrl('blog')?>"><span><?php echo $this->__('Blog') ?></span></a></li>
并且还尝试了这个:
<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>
在top.phtml中。该链接按预期显示。
但它不像本机链接那样显示按钮的活动状态(文本周围的矩形)。
这是页面:
http://pro-tools-training.com/new -magento2/index.php/
(单击导航中的所有链接,您将看到除博客外它们都保持活动状态)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能遇到 PHP 字符串比较问题。尝试使用
strcmp
。另外,尝试使用
getRequest()->getOriginalPathInfo()
而不是getAlias()
You may be having PHP string comparison issues. Try using
strcmp
.Also, try
getRequest()->getOriginalPathInfo()
instead ofgetAlias()
感谢您的提示,
我最终使用了
很多很多感谢!
Thanks for the tip
I ended up using
many many thanks!