When I use this code in layout Everything is good

    <reference name="head">
        <action method="addItem"><type>skin_js</type><name>js/chocolatebox/chocolatebox.js</name></action>
        <action method="addItem"><type>js_css</type><stylesheet>chocolatebox/css/style.css</stylesheet></action>
    <reference name="product.info">
    <action method="setTemplate">

But I want to apply to my template using blocks. When i doing this my template is destroying

class Chocolate_Box_Block_Catalog_Product_View extends Mage_Catalog_Block_Product_View

    public function _beforeToHtml(){
//       /die();


  • could you please look for error messages, increase the error output and activate dev mode? Also could you look at which line the html output stops and show this line of the template/php class? – Flyingmana Nov 24 '14 at 13:36
  • I'd be surprised if the chocolatebox/chocolatebox.phtml template is being set correctly by this layout XML - the <action /> tag needs to either be a child of a block or <reference /> tag OR it needs to have a block="" attribute declaration. – benmarks Nov 24 '14 at 14:38
  • Also, minor points (not the issue): _beforeToHtml() should be protected not public scope, and it should return either the parent or $this. – benmarks Nov 24 '14 at 14:51
  • And in conclusion, try instantiating your class directly in a workbench script to see if there are unrelated issues. – benmarks Nov 24 '14 at 14:52

The setTemplate should be called from the _construct function. As Ben Marks commented it should work from _beforeHtml tho. refactor the block class to look something like this:

class Chocolate_Box_Block_Catalog_Product_View extends Mage_Catalog_Block_Product_View

    public function _construct(){
  • No it doesn`t help – Sergey Nov 24 '14 at 13:16
  • Maybe problem in layout?? – Sergey Nov 24 '14 at 13:25
  • Could be but without any further info I won't be able to help you find the issue – Sander Mangel Nov 24 '14 at 13:48
  • "..._beforeToHtml will be to late to manipulate the template" No it's not ;-) – benmarks Nov 24 '14 at 14:25
  • 2
    Sitting in Damian's docker presentation at the moment. They pay me to multitask. – benmarks Nov 24 '14 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.