0
votes

I'm having a very peculiar problem.

I created a module which has it's own layout xml, and in the correct handle has a

<reference name="product_list">
    <action method="setTemplate"><template>rebates/product/list.phtml</template></action>
</reference> 

to update to use the correct template.

I also rewrote the module to use my block class Company_Module_Block_List extends Mage_Catalog_Block_Product_List.

I am using Alan Storms commerecebug, so I know the block is being used. Also I looked at the page layout xml using ?showLayout and I see that the setTemplate method is being called.

When I call

 public function _construct(){    
    parent::_construct();  
    echo $this->getTemplate();
 }

in the Block, the correct template shows up, but if I create

protected function _toHtml(){
  parent::_toHtml();
    echo $this->getTemplate();
}

It reverts to the old template?

1
Turn on template path hints, that will show you what template is actually being used at the moment of rendering. It's possible something is changing the template after the layout phase, perhaps a 3rd party module? - clockworkgeek
I did that, and it is using the wrong template. - josephtikva1
Actually, the call to echo $this->getTemplate(); in the _construct() method happens before the action method is applied, so it should show the wrong template. This leads me to believe some relevant information in your question is missing. - Vinai
What information would I be missing? Note that the parent constructor is called. And it is showing the correct template at that point....... - josephtikva1

1 Answers

0
votes

I ended up adding a

function _beforeToHtml(){
  $this->setTemplate('my_template.phtml');
}

I don't like it, but it works, and the module is not dependent on other layouts working....