我希望将Magento CE 1.6中的topLinks显示在静态块中。这是因为我的网站正在运行四个不同的商店[多商店 - 不同的域],并且只需要在两个商店上拥有topLinks,同时使用一个模板。
我确实尝试将php调用[getChildHtml('topLinks'(; ?>]转换为静态块中的块标签,但没有成功。深入研究了template_links的 xml [由不同的 xml 制成],但无法就如何在静态块中制作 {{block}} 来显示 topLinks 达成一致。
对静态块的调用已经到位,只需要帮助实现其中的topLinks。
任何帮助将不胜感激。
致以最诚挚的问候
晶圆厂
我的问题的微调:
基本上我需要修改页面.xml
从
<block type="page/template_links" name="top.links" as="topLinks"/>
自
<layout>
<static_block_top_links>
<reference name="header">
<action method="unsetChild">
<name>topLinks</name>
</action>
<block type="cms/block" before="-" name="some_name" as="topLinks">
<action method="setBlockId">
<name>some_static_block</name>
</action>
</block>
</reference>
</static_block_top_links>
<STORE_store>
<update handle="static_block_top_links" />
</STORE_store>
<STORE_law>
<update handle="static_block_top_links" />
</STORE_law>
使用 local.xml 来实现您的更改:
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<default>
<reference name="header">
<!-- Unset original toplinks block -->
<action method="unsetChild">
<name>topLinks</name>
</action>
<!-- Add static block in place with same alias -->
<block type="cms/block" before="-" name="some_name" as="topLinks">
<action method="setBlockId">
<name>some_static_block</name>
</action>
</block>
</reference>
</default>
</layout>
请注意,"some_name"可以是除"top.links"之外的任何内容,因为这会导致核心XML文件中的几个内容尝试在您的cms块上执行操作。
为了响应您的编辑,您可以轻松地仅为某些商店执行此操作,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<static_block_top_links>
<reference name="header">
<action method="unsetChild">
<name>topLinks</name>
</action>
<block type="cms/block" before="-" name="some_name" as="topLinks">
<action method="setBlockId">
<name>some_static_block</name>
</action>
</block>
</reference>
</static_block_top_links>
<STORE_myfirststore>
<update handle="static_block_top_links" />
</STORE_myfirststore>
<STORE_mysecondstore>
<update handle="static_block_top_links" />
</STORE_mysecondstore>
</layout>
对于拥有magento CE 1.6 +多商店多域并希望删除某些商店的topLinks的任何人,您好,这是正确的方法。
在您的应用程序/设计/前端/默认/主题/布局/中创建本地.xml
您本地.xml应该是这样的
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<STORE_mystore1>
<reference name="header">
<action method="unsetChild">
<name>topLinks</name>
</action>
</reference>
</STORE_mystore1>
<STORE_mystore2>
<reference name="header">
<action method="unsetChild">
<name>topLinks</name>
</action>
</reference>
</STORE_mystore2>
</layout>
将 mystore1 和 mystore2 替换为商店视图 [管理员 -> 管理商店 -> 商店视图名称 -> 代码] 下的代码]
确保以 UTF-8 格式对布局进行编码.xml
上传布局.xml在应用程序/设计/前端/默认/您的主题/布局/文件夹中。
刷新缓存。
我要感谢Daniel Sloof和Robert Popovic的投入。