Fishpig Magento/Wordpress集成-附加Wordpress自定义菜单不会';t设置活动状态

Fishpig Magento/Wordpress集成-附加Wordpress自定义菜单不会';t设置活动状态,wordpress,magento,fishpig,Wordpress,Magento,Fishpig,我在一家Magento商店使用。当我将它设置为使用自定义Wordpress菜单时(我在Wordpress中设置了一些类别层次结构),如果您单击了链接并且处于“活动”页面上,它不会添加任何活动状态。经过深入研究,/app/code/community/Fishpig/Wordpress/Model/Menu/Item.php具有以下内容: public function isItemActive() { return false; } 看来他们只是跳过了这一点?有人知道如何在这里设置活动

我在一家Magento商店使用。当我将它设置为使用自定义Wordpress菜单时(我在Wordpress中设置了一些类别层次结构),如果您单击了链接并且处于“活动”页面上,它不会添加任何活动状态。经过深入研究,/app/code/community/Fishpig/Wordpress/Model/Menu/Item.php具有以下内容:

public function isItemActive()
{
    return false;
}

看来他们只是跳过了这一点?有人知道如何在这里设置活动状态吗?

好的,这似乎可以解决问题,但嘿

public function isItemActive()
{
    $currurl = Mage::helper('core/url')->getCurrentUrl();
    $linkurl = $this->getUrl();
    if(strstr($linkurl, $currurl)){
        return true;
    }
    else {
        return false;
    }
}
获取当前url,获取博客url,如果它们匹配,请将“活动状态”设置为true。然后我使用了一点jQuery将父级的状态设置为活动状态,因为上面只设置了当前链接:

$('#nav li.nav-3 ul li.level1.active').parent().parent().addClass("active");

…其中li.nav-3是父博客链接

用/app/code/community/Fishpig/Wordpress/Model/Menu/Item.php中的以下代码替换isItemActive函数。这对我有用

public function isItemActive() {
        $myblogUrl = Mage::helper('wordpress/abstract')->getBlogRoute();
        $mycurrentUrl = preg_replace('/\?.*/', '', Mage::helper('core/url')->getCurrentUrl());
        if (in_array($myblogUrl, explode("/", $mycurrentUrl))) {
            return true;
        } else {
            return false;
        }
    }

这个问题只是一个简单的失误。。Magento在所有URL中使用“/”,$currentUrl从不匹配$currentUrl,因此。更正只是为了删减“/”我知道有一个迟来的回复,但我认为这可能会对某人有所帮助

public function isItemActive()
{
    $currentUrl = Mage::getUrl('*/*/*', array('_current' => true, '_use_rewrite' => true));

    if (strpos($currentUrl, '?') !== false) {
        $currentUrl = substr($currentUrl, 0, strpos($currentUrl, '?'));
    }

    return $currentUrl === rtrim($this->getUrl(), '/');
}

感谢Sport以完美的结构给出了我的答案。