views:

222

answers:

4

I have in my config.ini the titles of my pages In my Bootstrap.php I have

$title  = $config->title;
Zend_Registry::set('title',$title);
$view->headTitle($title);

In my layout.phtml I have:

echo $this->headTitle();

That does not work. The title is blank. What should I do?

A: 

Aren't you forgetting to read it back from the Registry? Zend_Registry::get('title');?

Chris
not really...I have that registered $title = $config->title; Zend_Registry::set('title',$title);
Roger Nem
Yea but when you read it in the view, you need to read it back using Zend_Registry::get()
Chris
Im doing it: $title = $config->title; Zend_Registry::set('title',$title); $varrr = Zend_Registry::get('title');$view->headTitle($varrr);Does not work
Roger Nem
+1  A: 

Do you return the view in the bootstrap after you are done with it?

return $view;
Iznogood
A: 

Hello,

As lznogood pointed out, are you setting the view correctly in the boostrap class?

It should look something like:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    function _initView()
    {
        $view = new Zend_View($this->getOptions());
        ...
        $view->headTitle($title);

        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
            'ViewRenderer'
        );
        $viewRenderer->setView($view);

        return $view;
}

Another example can be found here.

Gastón
A: 

My boostrap is not in the class but in a file (boostrap.php) like this:

$title  = $config->title;
Zend_Registry::set('title',$title);
$varrr = Zend_Registry::get('title');

Zend_Layout::startMvc(array('layoutPath'=>'../application/layouts'));
$view = Zend_Layout::getMvcInstance()->getView();
$view->headTitle($title);

$view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper');
$view->addHelperPath('Forms/View/Helper', 'Forms_View_Helper');

$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);

$front->dispatch();

What is wrong here that it cant get the title?

Roger Nem