Magento:如何将块分配给添加到CMS页面的父块

时间:2012-05-01 11:14:26

标签: xml magento content-management-system block magento-1.6

我希望你能理解我的问题!!

以下问题与在Magento CMS页面中分配和引用块有关。

问题

我有一个名为主页的cms页面。此页面的内容为

{{block type='core/template' name='homepage_html' template='page/html/homepage.phtml'}}

在page / html / homepage.phtml中,我的网站主页有一些基本的html。

- >到目前为止,一切正常。

我想从我的aw_blog模块中提取最新帖子。我有一个文件aw_blog / homepage_posts.phtml,如果我将此代码添加到cms.xml,它可以正常工作

<cms_index_index translate="label">
    <reference name="content">
        <block type="blog/blog" name="home_blog" template="aw_blog/homepage_posts.phtml"/>
    </reference>
</cms_index_index>

问题在于它在我的页面/ html / homepage.phtml文件中的内容下添加了帖子。

我在我的页面/ html / homepage.phtml中有这一行,我想要显示的帖子列表

<?php echo $this->getChildHtml('home_blog') ?>

并尝试引用homepage_html代替我的cms.xml文件中的内容

<cms_index_index translate="label">
    <reference name="homepage_html">
        <block type="blog/blog" name="home_blog" template="aw_blog/homepage_posts.phtml"/>
    </reference>
</cms_index_index>

但没有快乐!!!

问题

所以我的问题是,有没有办法将最新的帖子块分配到homepage_html块,以便使用$ this-&gt; getChildHtml()方法绘制最新帖子。

感谢您的时间。

1 个答案:

答案 0 :(得分:0)

您应该尝试在“page / html / homepage.phtm”中呼叫您的孩子,我喜欢这样:

<?php echo $this->getChildHtml('home_blog') ?>