Roger Nem
Roger Nem

Reputation: 31

$this->headTitle() does not work

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?

Upvotes: 3

Views: 2357

Answers (3)

Gaston
Gaston

Reputation: 1848

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

It should look something like this:

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;
    }    // Added missing '}' brace
}

Another example can be found here.

Upvotes: 2

Chris
Chris

Reputation: 884

Aren't you forgetting to read it back from the Registry? You can do that with

Zend_Registry::get('title');

Upvotes: 0

Iznogood
Iznogood

Reputation: 12843

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

return $view;

Upvotes: 2

Related Questions