2

my phtml file does not display after applying action method="setTemplate"

<?xml version="1.0"?>
  <layout version="0.1.0">
    <default>
      <reference name="content">
        <action method="setTemplate">
           <template>sidesupport/sidesupport.phtml</template>
        </action>
      </reference>
    </default>
  </layout>
1
  • just as @Reindex 'Em All said, content is a core/text_list block, which extends from Mage_Core_Block_Abstract, and does not have a setTemplate method. The one you should be referencing should be the root block, which is a page/html block extending from Mage_Core_Block_Template.
    – d.yuk
    Jan 21, 2015 at 7:48

4 Answers 4

7

i got solution

<layout version="0.1.0">
  <default>
    <reference name="content">
        <block type="core/template" name="sidesupport">
            <action method="setTemplate">
               <template>sidesupport/sidesupport.phtml</template>
            </action>
        </block>
    </reference>
  </default>
</layout>
2
  • Where the issue?
    – Amit Bera
    Jan 21, 2015 at 9:53
  • i just set "template" in <block> Jan 21, 2015 at 10:05
5

You can't call setTemplate on content block. It should be called on root block.

<layout_update_handle>
    <reference name="root">
        <action method="setTemplate"><template>some/template.phtml</template></action>
    </reference>
</layout_update_handle>
2

you can not use setTemplate directly in content block.

if you want to add sidebar for all pages must have to add in your main template file like page.xml and then set it to your theme.

for example if you want to set one custom block in header

<default translate="label" module="page">
        <label>All Pages</label>
        <block type="page/html" name="root" output="toHtml" template="page/3columns.phtml">
<block type="page/html_header" name="header" as="header">
         <block type="core/template" name="addthis_sharetool" after="-" >
                    <action method="setTemplate"><template>addthis/sharingtool/social_share.phtml</template></action>
        </block>
   </block>
  </block>
 </default>

and in your main phtml file just grab it like

   <?php  echo $this->getChildHtml('addthis_sharetool') ?>

hope this will sure help you.

1

Content block is of type core/text_list .since text_list block doesn't have a setTemplate method, you cant call that method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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