我正在为自定义模块编写一个新的布局文件。作为其中的一部分,我需要包括Toplinks,例如。登录,CART +(数量),我的帐户,愿望清单以及最近查看的其他内容。我的布局文件看起来像是如此,

  <?xml version="1.0"?>
  <layout version="0.1.0">
<dynamicblocks_index_index>
    <block type="core/template" name="root" output="toHtml" template="dynamicblocks/index.phtml" >
        <block type="page/template_links" name="top.links" as="topLinks"/>
        <block type="reports/product_viewed" before="right.permanent.callout" name="right.reports.product.viewed" template="reports/product_viewed.phtml" />
    </block>
</dynamicblocks_index_index>

我获得了从page.xml加载toplink的链接

  <block type="page/template_links" name="top.links" as="topLinks"/>

我相信这就是在主页上加载正确信息的原因,因为当我评论所有顶部链接时,所有顶部链接都会消失。但是在我的自定义布局中,它只能加载一个链接(登录)。我也看不出我的布局文件是错误的或错误的,因为它可以按照我的预期加载最近查看的产品。

我遇到的问题是,顶级链接仅返回链接中的日志。对此有什么想法吗?

有帮助吗?

解决方案

为了获取页面以显示我想要的链接,我必须告诉XML以删除某些文件。这是我更新的XML

  <dynamicblocks_index_index>

    <reference name="root">
        <action method="setTemplate"><template>dynamicblocks/index.phtml</template></action>
    </reference>   

    <reference name="header">
        <remove name="store_language" />
        <remove name="catalog.topnav" />
        <remove name="top.search" />
    </reference>

    <!-- <block type="reports/product_viewed" before="right.permanent.callout" name="right.reports.product.viewed" template="reports/product_viewed.phtml" /> -->

</dynamicblocks_index_index>

其他提示

这个答案是基于 讨论.

在继续之前,您必须检查一下 回答 为了正确添加新的布局模板。

您的布局文件应该看起来像:

<?xml version="1.0"?>
<layout version="0.1.0">
    <dynamicblocks_index_index>
        <reference name="root">
            <action method="setTemplate">
                <template>module/file/path/template.phtml</template>
            </action>
        </reference>
    </dynamicblocks_index_index>
</layout>

在您的模板文件中,您告诉您编写的代码是: $this->getChildHtml();
实际上的问题是您尚未指定块的名称,这就是为什么您是否只需要 顶级链接. 。因此,模板文件中的代码可能看起来像:

$this->getChildHtml('top.links');
许可以下: CC-BY-SA归因
scroll top