0

I have tried to pass a value from controller to layout using this but it does not work:

foreach ($user_info_details as $details):
    $first_name = $details['first_name'];
endforeach;
Zend_Layout::getMvcInstance()->assign('first_name',$first_name);

and retrieve it using

<?php echo $this->layout()->first_name; ?> 

but it shows blank in every case

Felix Yan
  • 14,841
  • 7
  • 48
  • 61
Arnab
  • 1

1 Answers1

3

To output values to your view easily, in your controller use:

$this->view->first_name = $first_name;

And in your view, access it like this:

echo $this->first_name;
Jeremy Harris
  • 24,318
  • 13
  • 79
  • 133
  • i know this but this will create redundancy .. i want to send the value from controller to laypout – Arnab Feb 03 '12 at 06:43
  • This will help you then: http://stackoverflow.com/questions/1537700/sending-variables-to-the-layout-in-zend-framework – Jeremy Harris Feb 03 '12 at 13:28