I have the XML below in my layout. Notice that both category.products and product_list have the block type amshopby/catalog_layer_view_top. The reason for this is that under certain conditions category.products will render this block and in all other circumstances product_list will render the block. If I remove one of the references to this block so that it is only in my XML once, the block renders its content. When it is in the XML twice, a method within the template (canShowBlock) becomes false and the content does render.
<catalog_category_layered>
<remove name="catalog.leftnav" />
<remove name="enterprisecatalog.leftnav"/>
<reference name="left">
<block type="amshopby/catalog_layer_view" name="amshopby.navleft" before="-" template="catalog/layer/view.phtml"/>
</reference>
<reference name="category.products">
<block type="amshopby/catalog_layer_view_top" name="amshopby.navtop.category.view" template="amasty/amshopby/view_top.phtml">
<block type="core/template" name="filter.search.category.view" as="filterSearch.category.view" template="catalogsearch/form.filter.phtml"/>
</block>
</reference>
<reference name="product_list">
<block type="amshopby/catalog_layer_view_top" name="amshopby.navtop" template="amasty/amshopby/view_top.phtml">
<block type="core/template" name="filter.search" as="filterSearch" template="catalogsearch/form.filter.phtml"/>
</block>
</reference>
<reference name="content">
<block type="amshopby/top" name="amshopby.top" before="category.products" template="amasty/amshopby/top.phtml"/>
</reference>
</catalog_category_layered>
The block is inserted as it should be. However, the template content is wrapped in the condition below and canShowBlock() is returning false when the block is in the XML twice.
<?php /** @var $this Amasty_Shopby_Block_Catalog_Layer_View_Top */ ?>
<?php if($this->canShowBlock()):
//Contents of template
?>
The canShowBlock() method (shown below) is within class Amasty_Shopby_Block_Catalog_Layer_View which, eventually, extends Enterprise_Search_Block_Catalog_Layer_View.
canShowOptions() is what "breaks" (returns false) when the block is in the XML twice. This method is called from Mage_Catalog_Block_Layer_View
public function canShowBlock()
{
if ($this->canShowOptions()){
return true;
}
$cnt = 0;
$pos = Mage::getStoreConfig('amshopby/block/state_pos');
if (!$this->_notInBlock($pos)){
$cnt = count($this->getLayer()->getState()->getFilters());
}
return $cnt;
}