Zend: How to add a web page title to all my looks?

Now I need to add a title to all my views separately:

<head>
       <title>TestProject - Home</title>
</head>

and

<head>
       <title>TestProject - Dashboard</title>
</head>

Now, if I want to change the TestProject part of the name, I have to change it in all of my views. How can I mention this in BootStrap.php and add it to all kinds? And whenever I have to change it, I will change it in one place.

+2
source share
5 answers

In bootstrap.php

protected function _initViewHelpers() {
    $view = new Zend_View();
    $view->headTitle('Main Title')->setSeparator(' - ');
}

In any view /.phtml

<?php 
    $this->headTitle()->prepend('Page Title');
    echo $this->headTitle();
?>
+4
source

headTitle. ( http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.headtitle).

// setting the controller and action name as title segments:
$request = Zend_Controller_Front::getInstance()->getRequest();
$this->headTitle($request->getActionName())
     ->headTitle($request->getControllerName());

// setting the site in the title; possibly in the layout script:
$this->headTitle('Test Project');

// setting a separator string for segments:
$this->headTitle()->setSeparator(' / ');

:

$this->view->headTitle('The page name')

:

<title>Test Project / The page name</title>

, script, :

<?php echo $this->headTitle() ?>
+9

. , . "home" "dashboard" , .

+4

This is the best way to set the page title in the controller. If you want to set a new title, use it.

public function init()
 {
    $this->view->headTitle('My title'); 
 }

If you want to add a title with an existing name, use

$this->view->headTitle()->setSeparator(' - ')->prepend('Manager'); 
+2
source

I think you can do it with js as you just place the title = TestProject and then on each page that you could with javascript read the title and then combine the additional header

if you use something like master pages

+1
source

All Articles