Zend:如何在所有视图中添加网页标题? [英] Zend: How to add webpage title in all my views?

查看:105
本文介绍了Zend:如何在所有视图中添加网页标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,我必须像这样在所有视图中分别添加标题:

For now I have to add title in all my views separately like this:

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

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

现在,如果我想更改标题的 TestProject 部分,则必须在所有视图中进行更改.如何在 BootStrap.php 中提及此问题并将其添加到所有视图中?而且每当我必须更改此位置时,我都会在一个地方更改此位置.

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

推荐答案

Bootstrap.php

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

在任何视图/.phtml

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

这篇关于Zend:如何在所有视图中添加网页标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆