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

The code above results in $this->layout()->content being shown in every place in layout file. But i need granularity to show the result of some actions in another place (E.g. in a right column or left column).

This is layout file:

<div class="center_col"><?php echo $this->layout()->content; ?></div>
<div class="right_col">?????</div>

How i can show result of some actions in the provided (above) .right_col ?

chrisjlee
  • 21,691
  • 27
  • 82
  • 112
afsane
  • 1,889
  • 6
  • 25
  • 40
  • 2
    Could you take a step back and look at your question again and rewrite it? I am trying, but I *really* cannot make sense of what you are asking. – Aron Rotteveel Apr 15 '11 at 10:23
  • Possible dublicate of this http://stackoverflow.com/questions/1627962/how-do-i-include-header-and-footer-with-layout-in-zend-framework – DarkLeafyGreen Apr 15 '11 at 10:36

1 Answers1

5

One way would be to define your own layout placeholders (i.e. other than 'content'). For example:

<div class="center_col"><?php echo $this->layout()->content; ?></div>
<div class="right_col"><?php echo $this->layout()->rightColumn; ?></div>

Then in your action you need to tell the Zend_Layout to use the new content placeholder, e.g.:

public function testAction() { 
    // ....
    // render output of this action in 'rightColumn' placeholder
    // rather than in default 'content' placeholder.      
    $this->view->layout()->setContentKey('rightColumn');            
}

Alternatively, you could also have a look at placeholder view helper. With the helper, you could do e.g.:

<div class="center_col"><?php echo $this->layout()->content; ?></div>
<div class="right_col"><?php echo $this->placeholder('right_col'); ?></div>

The helper has many functions that can ease management of its content.

Hope this will be helpful.

Marcin
  • 215,873
  • 14
  • 235
  • 294