-- vadim gavrilov <[email protected]> wrote
(on Sunday, 15 March 2009, 12:07 PM +0200):
> I have the following structure:
<cut-n-paste>
> but for some reason the $this->breadcrumbs array has only one element which
> was
> added in the BaseEndController class. the element that was added in the
> indexcontroller class was not actually added to the array and is not shown
> when
> it prints it.
>
> Any idea why, Or how to solve it? any other approach for something similar?
In your BaseEndController class' init() method, you're not calling
parent::init().
> class BaseMasterController extends Zend_Controller_Action
> {
> public $view;
> public $breadcrumbs = array();
>
> public function init()
> {
> # Define module path
> defined('MODULE_PATH')
> or define('MODULE_PATH', Zend_Controller_Front::getInstance()->
> getModuleDirectory() . '/');
>
> # Define controller path
> defined('CON_PATH')
> or define('CON_PATH', Zend_Controller_Front::getInstance()->
> getModuleDirectory() . '/');
>
> # Set layout and views directories
> Zend_Layout::startMvc( MODULE_PATH .'/layouts/scripts' );
>
> # Init views object
> $this->view = Zend_Layout::getMvcInstance()->getView();
> $this->view->doctype( Zend_Registry::get('config')->layout->doctype );
> $this->view->setScriptPath( MODULE_PATH . 'views/scripts/' );
> $this->viewRenderer = $this->_helper->getHelper('viewRenderer');
> $this->viewRenderer->setView($this->view)->setViewBasePathSpec(
> MODULE_PATH . 'views/scripts/' )->setViewScriptPathSpec(':controller
> /:action.phtml');
>
> # Build Helpers
> $this->view->addHelperPath( MODULE_PATH . 'views/helpers/', 'Helper');
>
> # setting content type and character set
> $this->view->headMeta()->appendHttpEquiv('X-UA-Compatible','IE=
> EmulateIE7')->appendHttpEquiv('Content-Type','text/html; charset=UTF-8')->
> appendHttpEquiv('Content-Language', 'en-US');
>
> # setting a separator string for segments:
> $this->view->headTitle()->setSeparator(' :: ');
>
> # Load the DB Adapter
> $this->db =
> Zend_Db::factory(Zend_Registry::get('config')->production->
> database);
>
> # Clean Globals
> $this->input = new Input;
> }
> }
>
> class BaseEndController extends BaseMasterController
> {
> public function init()
> {
> # Set Up view properties
> $this->view->breadcrumbs = array();
>
> # Create the base breadcrumb
> $this->view->breadcrumbs[] = $this->BB( $this->lang->_('GL1'),
> array('index', 'index', 'admin'));
> }
> }
>
> class Admin_IndexController extends BaseEndController
> {
>
> public function indexAction()
> {
> $this->view->breadcrumbs[] = "123";
> $this->viewRenderer->render('index');
> }
> }
>
> then in the layout i am doing:
>
> <?php if( $this->breadcrumbs ): ?>
> <ul class="breadcrumbs">
> <?php foreach($this->breadcrumbs as $crumb): ?>
> <li><?php echo $crumb; ?></li>
> <?php endforeach; ?>
> </ul>
> <?php endif; ?>
>
> but for some reason the $this->breadcrumbs array has only one element which
> was
> added in the BaseEndController class. the element that was added in the
> indexcontroller class was not actually added to the array and is not shown
> when
> it prints it.
>
> Any idea why, Or how to solve it? any other approach for something similar?
>
> Thanks.
>
>
> --
> Vincent Gabriel.
> Lead Developer, Senior Support.
> Zend Certified Engineer.
>
>
>
>
--
Matthew Weier O'Phinney
Software Architect | [email protected]
Zend Framework | http://framework.zend.com/