<reference name="left">
<block type="catalog/navigation"
name="cms_catalog"
template="catalog/catalog.phtml"/>
<block type="catalog/product_new"
name="home.catalog.product.new"
alias="product_new"
template="catalog/product/newbar.phtml" />
<block type="amreview/sidebar"
name="amreview_sidebar"
template="amreview/sidebar.phtml"/>
<block type="catalog/product"
template="catalog/product/specials.phtml" />
</reference>
我想提出一个条件来确定何时使用登录,然后不输出<block type="catalog/product" template="catalog/product/specials.phtml" />
块。我该怎么办?
答案 0 :(得分:1)
您可以从customer_logged_in布局句柄中删除特殊区块。
例如,您可以像这样修改布局文件:
<layout>
...
<customer_logged_in>
<remove name="specials" />
</customer_logged_in>
</layout>
在您发布的布局代码中,您需要为特殊区块添加名称并在删除节点中引用它(我只使用“特殊”作为示例)。
如果你想实现相反的效果,还有一个customer_logged_out句柄。
答案 1 :(得分:0)
您可以在“左”内执行此操作。在相应的.phtml
文件中,您可能会找到以下行:
$this->getChildHtml();
,如果没有传递参数,将按顺序呈现每个块。
您可以将其替换为:
$this->getChildHtml("cms_catalog");
$this->getChildHtml("home.catalog.product.new");
$this->getChildHtml("amreview_sidebar");
if ($condition) { // Find the approriate variable to define the condition.
$this->getChildHtml("specials");
}