Thanks mate :).
On Thu, Nov 19, 2009 at 8:54 AM, Matthew Weier O'Phinney <matt...@zend.com> wrote: > -- Juan Felipe Alvarez Saldarriaga <jfalva...@vesifront.org> wrote > (on Thursday, 19 November 2009, 08:10 AM -0500): >> I have a page with like four tabs, so I want to reuse each tab html >> and logic, how to achive this? create a view helper for each tab? I >> was looking at the current view helpers code and all of them returns >> an string with all the html, it's possible to use a view? > > If you extend Zend_View_Helper_Abstract, the View object will be > injected into your helper; alternately, you can simply add a setView() > method on your helper, and the view will be injected after instantiation > but prior to execution of the helper. > >> a phtml file to no mix logic with the html? I was thinking something >> like this: >> >> class Ceiba_View_Helper_News extends Zend_View_Helper_Abstract >> { >> protected $_view = null; >> >> public function setView( Zend_View_Interface $view ) >> { >> $this->_view = $view; >> } > > If you extend Zend_View_Helper_Abstract, setView() is already defined, > and sets the public $view property -- so access is simply via > $this->view. > >> public function news() >> { >> /** some logic **/ >> $this->_view->blah = "blah1"; >> >> // I'm adding this path to the bootstrap: >> $view->addScriptPath( APPLICATION_PATH . "/views/scripts" ); >> return $this->_view->render( "partials/news.phtml" ); >> } >> } > > Yes, that will work fine, and is a good approach. > > -- > Matthew Weier O'Phinney > Project Lead | matt...@zend.com > Zend Framework | http://framework.zend.com/ >