I am trying to access block class method from controller and set some value to block class property. The method is being accessed but when I try to print the property in .phtml file it is NULL. Here is my code:



    class Amactech_Events_IndexController extends Mage_Core_Controller_Front_Action{
        public function indexAction(){

            $block->setFeedback("wrwqerqwer fasdfasdf vxzcvzxcv");

            return $this->renderLayout();





  class Amactech_Events_Block_Events extends Mage_Core_Block_Template{

    public $_feedback;

    public function setFeedback($feedback){
      echo $feedback;
      $this->_feedback = $feedback;

    public function getFeedback(){
      echo "get feedback"; /*This line is being printing which means I am getting in this method*/
      return $this->_feedback;




    echo $this->getFeedback();

So I am accessing block setFeedback() method and setting $_feedback value. I print something string inside setFeedback() and getFeedback() methods to check whether I am getting into these methods. The printing string is shown which means I am getting into the methods but when I assign some value to property and try to print the property is shows NULL.

1 Answer 1


You can set data in your block using $this->getLayout()->getBlock('blockname')->setData('data'); methos

Here is example for set data from controller get in template


public function indexAction()


    <reference name="content">
        <block type="core/template" name="blockname" template="template.phtml" />


    echo $this->getMyname();
  • If this solution works for you can accept or upvote this answer to help someone Dec 28, 2016 at 11:23

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.