A View Helper is a class, for example Zend_View_Helper_Doctype. Like any class, 
you can query the database, and use the results to create a string containing 
the HTML markup you need. Usually it's good to implement PHP's __string() 
method so the resulting object can be directly echoed or cast to string. It 
should also implement a method similar to its name to return the object or 
accept some parameters and then return the object.

As an example, you could have a custom helper: My_View_Helper_NavMenu. It has a 
method My_View_Helper_NavMenu::navMenu() which returns the object (i.e. $this) 
after it has been initialised and completed any queries needed. It should also 
have My_View_Helper_NavMenu::__toString() which returns the HTML markup to 
insert. You should register the locations of custom helpers with the View using 
Zend_View_Abstract::addHelperPath(), i.e.

$view->addHelperPath('My/View/Helper', 'My_View_Helper'); // path and classname 
prefix

Then you can call the helper from your view:

<? echo $this->navMenu() ?>

Read the reference guide for lots more details and examples.

 Pádraic Brady

http://blog.astrumfutura.com
http://www.survivethedeepend.com
OpenID Europe Foundation Irish Representative





________________________________
From: neobeacon <[email protected]>
To: [email protected]
Sent: Sunday, August 30, 2009 11:21:18 AM
Subject: Re: [fw-general] How to add a database genarated menu for a layout


view helper is a .phtml file .Can I genarate it's code from database
-- 
View this message in context: 
http://www.nabble.com/How-to-add-a-database-genarated-menu-for-a-layout-tp25209362p25210306.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to