Add CMS page to topmenu only with XML
Pergunta
In CMS->page->Design->DesignXML
I add this:
<reference name="top.menu">
<action method="addLink" translate="label title" module="customer">
<label>Home</label>
<url></url>
<title>Home</title><prepare>true</prepare>
<urlParams/>
<position>5</position>
</action>
</reference>
This gives an error (because of the name="top.menu"
) but what would be the correct XML for the top menu (not the top.links)
Solução
Try using top.links
instead of top.menu
in your reference node.
<reference name="top.links">
<action method="addLink" translate="label title" module="customer">
<label>Home</label>
<url>/</url>
<title>Home</title><prepare>true</prepare>
<urlParams/>
<position>5</position>
</action>
</reference>
It's not possible to simply add links to the category navigation (top.menu
> catalog.topnav
).
You can add child blocks to top.menu
, since it is a core/text_list
block, but they will be rendered before or after the <div class="nav-container">
of the catalog.topnav
block.
Outras dicas
You can create a block inside top.menu
with your custom links.
Add this in your theme's local.xml
file:
<reference name="header">
<reference name="top.menu">
<block type="page/template_links" name="top.menu.custom-links">
<action method="addLink" translate="label title">
<label>New Link</label>
<url>my-url</url>
<title>New Link</title>
<prepare>true</prepare>
<urlParams helper="core/url/getHomeUrl"/>
<position>60</position>
</action>
</block>
</reference>
</reference>
I think this is the easiest way.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange