题
我正在尝试自定义标题菜单,并且 垂直菜单 (左菜单)在Magento CMS中
当我单击类别时,我将被重定向到下一页,但是该页面上不再显示类别的完整列表。我只希望在用户正在通过类别列表中导航的所有页面上显示完整列表。
我在CMS->页面 - >主页 - >设计 - >布局更新XML上使用以下代码
<reference name="left">
<!--<block type="catalog/navigation" name="catalog.leftnav" after="currency" template="catalog/navigation/left.phtml"/>-->
<block type="catalog/navigation" before="-" name="catalog.vertnav" template="catalog/navigation/vert_nav.phtml"/>
</reference>
如何在所有页面中显示左菜单以及如何自定义标头菜单 关于美国博客的主页
我还在Stackoverflow上发布了同样的问题,请查看 这些 FR屏幕截图
请建议我开发好看的Magento网站
解决方案
如果您查看/design/frontend/base/default/template/catalog/navigation/left.phtml,您将看到此代码:
...
<?php $_categories = $this->getCurrentChildCategories() ?>
...
这意味着您可以获得当前类别后代的类别。您应该创建自己的左导航菜单。这很简单。
/design/frontend/default/yourtheme/template/catalog/navigation/left.phtml
<?php
$_menu = $this->renderCategoriesMenuHtml(0, 'level-top');
?>
<?php if($_menu): ?>
<div class="category">
<div class="title"><?php echo $this->__('Category menu:') ?></div>
<ul class="submenu">
<?php echo $_menu ?>
</ul>
</div>
<?php endif ?>
在这种情况下,您将根类别设置为父,您将在左侧栏中看到所有导航树。
您可以从顶部菜单中删除类别导航以自定义。有很多方法。就我而言,我需要创建自己的菜单:/design/frontend/base/default/layout/page.xml
<block type="page/html_header" name="header" as="header">
...
<block type="core/text_list" name="top.menu" as="topMenu" translate="label">
<label>Navigation Bar</label>
<block type="page/html_topmenu" name="catalog.topnav" template="page/html/topmenu.phtml"/>
</block>
...
</block>
至
<block type="page/html_header" name="header" as="header">
<block type="page/html_wrapper" name="top.header.menu" as="topHeaderMenu" translate="label">
<label>Top Menu</label>
<action method="setElementClass"><value>header_menu</value></action>
<block type="page/template_links" name="custom.menu.links">
<action method="addLink"><label>Home</label><url>/</url><title>Home</title><prepare></prepare><urlparams></urlparams><order>10</order></action>
...
</block>
</block>
</block>
如果您在顶部菜单中使用类别项目,则应在类别树中为顶部菜单创建一些节点。并像我们为左菜单导航所做的那样称呼它。
更新:您可以参考以应用CSS:
<reference name="head">
<action method="addItem"><type>skin_css</type><name>css/your_style.css</name><params/></action>
</reference>