It looks like you need to study viewing helpers . Viewing helpers can be simple as it returns the version number of the application or as complex as adding html to multiple place owners. For example:
layout.phtml:
<h1><?php echo $this->placeholder('title'); ?> <div class="sidebar"> <?php echo $this->placeholder('sidebar'); ?> </div> <div class="content"> <?php echo $this->layout()->content; ?> </div>
in your foo.phtml script view for example:
<?php $this->placeholder('title')->set('Hello World!'); $this->placeholder('sidebar')->set('Hello World!'); ?> <h1>Bar Bar!</h1>
Now, if you want to use this again and again, you can do this:
<?php class Zend_View_Helper_MyHelper extends Zend_View_Helper_Abstract { public function myHelper() { $this->view->placeholder('title')->set('Hello World!'); $this->view->placeholder('sidebar')->set('Hello World!'); return '<h1>Bar Bar!</h1>'; } }
Now replace the code in the foo.pthml file with:
<?php echo $this->myHelper();
Both examples of foo.phtml output:
Hello World!
Hello World!
Bar Bar!
Of course, this is a very simplified example, but I hope this helps you in the right direction. Happy hack!
Fatmuemoo
source share