0

I'm trying to set some custom data for my block in local.xml:

<cms_index_index>
    <reference name="after_body_start">
        <block type="core/template" template="custom.phtml">
            <action method="setCustomData"><string>Sample data</string></action>
        </block>
    </reference>
</cms_index_index>

I would now assume that I can access this data in my custom.phtml template like this:

echo $this->getCustomData;
// or 
echo $this->getData('custom_data');

But none of the above works and I can't figure out way?

0

I found the answer which was rather silly, the block needs to have a name for this to work:

<cms_index_index>
  <reference name="after_body_start">
    <block type="core/template" name="custom" template="custom.phtml">
        <action method="setCustomData"><string>Sample data</string></action>
    </block>
  </reference>
</cms_index_index> 

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.