Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Magento-从主页中删除活动状态_Php_Magento - Fatal编程技术网

Php Magento-从主页中删除活动状态

Php Magento-从主页中删除活动状态,php,magento,Php,Magento,我在top.phtml中有此代码,它在我的Magento商店中显示我的菜单项: <div class="header-nav-container"> <div class="header-nav"> <h4 class="no-display"><?php echo $this->__('Category Navigation:') ?></h4> <ul id="nav"> <li <?php i

我在top.phtml中有此代码,它在我的Magento商店中显示我的菜单项:

<div class="header-nav-container"> 
<div class="header-nav"> 
<h4 class="no-display"><?php echo $this->__('Category Navigation:') ?></h4> 
<ul id="nav"> 
<li <?php if(!Mage::registry('current_category')) { echo 'class="level0 active"'; } else { echo 'class="level0"'; } ?>><a href="<?php echo $this->getUrl('') ?>"><span><?php echo $this->__('Home') ?></span></a></li> 
<?php foreach ($this->getStoreCategories() as $_category): ?> 

<?php echo $this->drawItem($_category) ?> 
<?php endforeach ?> 
<li <?php if(!Mage::registry('current_category')) { echo 'class="level0 active"'; } else { echo 'class="level0"'; } ?>><a href="<?php echo $this->getUrl('catalogsale')?>"><span><?php echo $this->__('Sale Items') ?></span></a></li> 
</ul> 

</div>


    当未定义当前类别时,Home和Sale项目的行都通过代码
    if(!Mage::registry('current_category'))
    输出活动类别链接。检查当前控制器/操作,而不是检查类别

    以下是URL函数列表(用于获取控制器/操作):

    这样的代码应该可以工作。这取决于catalogsale是否是自定义控制器或操作的标识符,这取决于您的设置:

    if ($this->getRequest()->getControllerName() == 'catalogsale')
     // Output active class declaration
    
    /* Otherwise, try looking at the action name. */
    
    if ($this->getRequest()->getActionName() == 'catalogsale')
     // Output active class declaration
    

    我最终用一些javascript修复了这个问题。我在新页面中添加了以下内容:

    <script type="text/javascript">
    Event.observe(window, 'load', function() {
    $$('li.active').invoke('removeClassName','active');
    $$('li.newmenu').invoke('addClassName','active');
    });
    </script>
    
    
    事件。观察(窗口“加载”,函数(){
    $$('li.active')。调用('removeClassName','active');
    $$('li.newmenu')。调用('addClassName','active');
    });
    
    新菜单项应具有“newmenu”类,以便上述代码正常工作