In the view and layout scripts of my MVC application I regularly require access to convenience methods such as isLoggedIn()
or isAdmin()
. I would like to put these in a base view so that I can access them with $this->isLoggedIn()
or $this->isAdmin()
. What's the right way to do this?
I tried extending Zend_View with MY_Base_View. I then created a View resource and initialised it from my bootstrap. I know that its being initialised because the page title works fine. Here's the code from the resource:
$this->_view = new MY_Base_View();
$this->_view->headTitle('My page title!');
When I'm in the view script, however, if I print_r($this)
, it says the object is a Zend View object, (not MY_Base_View).
Have had similar problems with the layout to.
Thanks!