【发布时间】:2015-01-29 19:25:04
【问题描述】:
对不起,这个奇怪的标题,但我花了半天时间试图找到这个,我确信答案已经存在于某个地方,但我找不到它......所以我再次询问其他人有一天可能会找到的可搜索标题。
在响应式 magento 主题中,我希望 topLinks 块同时显示在仅在移动视图中可见的响应式菜单和页脚中。由于这两个地方都由 css 和 page-width 控制,我需要它们同时在模板中呈现。我在 page.xml 中有这个
<block type="page/html_header" name="header" as="header">
<... lots of other stuff ...>
<block type="page/template_links" name="top.links" as="topLinks"/>
<... lots of other stuff ...>
</block>
当我调用<?php echo $this->getChildHtml('topLinks'); ?> 时,这工作得很好,但是当我输入以下内容时,在 page.xml 中也只有页脚呈现而页眉不呈现。
<block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml">
<... lots of other stuff ...>
<block type="page/template_links" name="top.links" as="topLinks"/>
<... lots of other stuff ...> -->
</block>
我做错了什么,或者我如何克隆第二个位置的一个块的结果?
【问题讨论】:
-
我相信这是与名称或“as”部分的冲突。尝试更改底部的一个或两个(以及 getChildHtml 中使用的名称。
-
我试过了...我将 page.xml 中的页脚块更改为 as="topLinksCopy" 并更改了 footer.phtml 中的名称并呈现,但它也停止了页眉渲染。如果您更改 name="top.links",那么您会破坏功能,因为其他模块使用 addLink 操作将实际链接添加到 top.links。
-
嗨乔恩,看看这里:stackoverflow.com/a/10664584/1512654
标签: php xml magento zend-framework