![]() |
|
|||
|
Hi, I'm new to this forum and also to Zend Framework. I've been writing PHP code for more than 2 years already so I'm not a complete newbie.
I'm stll just trying to get used to ZF (have been playing with it just for a couple of weeks). What I want to achieve is, in the bootstrap file, to set the title of the pages to be like this: Code:
Some title - controller - action Thank you for your help ![]() This is how my bootstrap file looks like: [php] <?php error_reporting(E_ALL); // crucial for development environment, goes away in production defined('APPLICATION_PATH') or define('APPLICATION_PATH', dirname(__FILE__)); defined('APPLICATION_ENVIRONMENT') or define('APPLICATION_ENVIRONMENT', 'development'); Zend_Session::start(); $frontController = Zend_Controller_Front::getInstance(); $frontController->setControllerDirectory(APPLICATION_PATH . '/controllers'); $frontController->setParam('env', APPLICATION_ENVIRONMENT); Zend_Layout::startMvc(APPLICATION_PATH . '/layouts/scripts'); $view = Zend_Layout::getMvcInstance()->getView(); $view->doctype('XHTML1_STRICT'); $view->headTitle('Zend'); // HERE I NEED YOUR HELP $configuration = new Zend_Config_Ini( APPLICATION_PATH . '/config/app.ini', APPLICATION_ENVIRONMENT ); $dbAdapter = Zend_Db::factory($configuration->database); Zend_Db_Table_Abstract::setDefaultAdapter($dbAdapt er); $registry = Zend_Registry::getInstance(); $registry->configuration = $configuration; $registry->dbAdapter = $dbAdapter; unset($frontController, $view, $configuration, $registry, $dbAdapter); [/php] Last edited by risoknop; 01-29-2009 at 07:53 PM. |
|
|||
|
I don't think you will be able to achieve this in the bootstrap as the routing hasn't been done at this point so the controller and action aren't decided on.
I think the cleanest way to achieve this would be with a controller plugin. So you can retrieve the controller and action names from the request object.
__________________
Brenton Alker PHP Developer - Brisbane, Australia blog.tekerson.com | twitter.com/tekerson | brenton.mp |
|
|||
|
ye, you cant do that in bootstrap..
you can a) make controller plugin my_controller_plugin extends zend_controller_plugin_abstract b) make base class my_controller action extends zend_controller_action c) make a view helper d) you can copy/paste code in every controller but u can see whats wrong with that approach ![]() e) im sure there are at least 2-3 more thing you can try but they all come to same idea: you need to access zend_controller_request object and then you can use its getModuleName(), getControllerName() and getActionName() methods witch will return requested names.. Zend Framework: Documentation Last edited by Eugen; 01-30-2009 at 08:36 AM. |
|
|||
|
They are pretty straightforward, and the docs (Zend Framework: Documentation) are pretty good.
Front Controller Plugins in Zend Framework is also quite a good introduction (Google is your friend)
__________________
Brenton Alker PHP Developer - Brisbane, Australia blog.tekerson.com | twitter.com/tekerson | brenton.mp |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
| Designed by: Miner Skinz |
Powered by vBulletin® Version 3.8.4 Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Search Engine Friendly URLs by vBSEO 3.1.0 |
![]() |