Magento编辑导航结构

时间:2014-03-15 11:42:38

标签: magento navigation

需要在level-top中添加'div'标记。我试图在block / navigation.php中编辑它,但没有结果。 http://ipic.su/img/img7/fs/kiss_9kb.1394883580.png

1 个答案:

答案 0 :(得分:0)

首先,您应该将app/code/core/Mage/Catalog/Block/Navigation.php复制到app/code/local/Mage/Catalog/Block/Navigation.php,这样您才不会编辑核心。

打开app/code/local/Mage/Catalog/Block/Navigation.php并查找protected function _renderCategoryMenuItemHtml(第218行左右)。

查找以下代码:

    // assemble list item with attributes
    $htmlLi = '<li';
    foreach ($attributes as $attrName => $attrValue) {
        $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\"', $attrValue) . '"';
    }
    $htmlLi .= '>';

并替换为:

    // assemble list item with attributes
    $htmlLi = '<li';
    foreach ($attributes as $attrName => $attrValue) {
        $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '\"', $attrValue) . '"';
    }
    $htmlLi .= '>';

    if ($level==0) { 
         $htmlLi .= '<div>';
    }

寻找:

   $html[] = '</li>';

并将其更改为:

   if ($level==0) { 
        $html[] = '</div></li>';
   } else {
        $html[] = '</li>';
   }