我有一个名为Home的CMS页面,在Design->Layout Update Xml
中包含以下代码<reference name="content">
<block type="core/template" template="homepage/home.phtml">
<reference name="featured">
<block type="catalog/product_list" name="featured" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>2</category_id></action>
<action method="setColumnCount"><count>5</count></action>
</block>
</reference>
</block>
</reference>
和这个在首页/home. php
<div class="container home">
<div class="promo">
// Promo Here
</div>
<?php echo $this->getChildHtml('featured'); ?>
</div>
我的主要目标是试图让特色块插入到主页/主页。
在上面的CMS页面的当前布局xml中,它没有显示。xml文件中有问题,我已经修改了…代码
<reference name="content">
<block type="core/template" template="homepage/home.phtml" >
<block type="catalog/product_list" name="featured" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>2</category_id></action>
<action method="setColumnCount"><count>5</count></action>
</block>
</block>
</reference>
getchildtml ('featured');> 'featured'是块的名称,而不是引用。如果你想在模板中调用块,你将使用下面的块语法{{block type="catalog/product_list" name="featured" as="featured"模板="catalog/product/list. "phtml "}}
像这样修改代码,我认为块的名称"home_content"应该在那里。
<reference name="content">
<block type="core/template" name="home_content" template="homepage/home.phtml" >
<block type="catalog/product_list" name="featured" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>2</category_id></action>
<action method="setColumnCount"><count>5</count></action>
</block>
</block>
</reference>
希望对你有帮助。