Home > Backend Development > PHP Tutorial > yii pageTitle 怎么修改

yii pageTitle 怎么修改

WBOY
Release: 2016-06-06 20:29:03
Original
1266 people have browsed it

yii pageTitle 怎么修改

这是layouts/main.php的

<code><title>
<?php echo CHtml::encode($this->pageTitle); ?></title></code>
Copy after login
Copy after login

这一行代码的结果,其值在comfig/main.php里面定义好的

<code>return array(
    'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
    'name'=>'聚众网络科技有限公司',
    ),
</code>
Copy after login
Copy after login

name的值里面没有site这一字,

我的问题是怎么让这个site这一字不显示?

回复内容:

yii pageTitle 怎么修改

这是layouts/main.php的

<code><title>
<?php echo CHtml::encode($this->pageTitle); ?></title></code>
Copy after login
Copy after login

这一行代码的结果,其值在comfig/main.php里面定义好的

<code>return array(
    'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
    'name'=>'聚众网络科技有限公司',
    ),
</code>
Copy after login
Copy after login

name的值里面没有site这一字,

我的问题是怎么让这个site这一字不显示?

直接在views文件使用下面的方法指定就可以了:

第一

<code><?php $this->setPageTitle('Your Title Here');

// or


$this->pageTitle = 'Your Title Here'; 
?></code>
Copy after login

第二

或者你可以直接重写setPageTitle这个方法:

<code>class YourController extends Controller
{
  public function setPageTitle($value){
    $this->pageTitle = Yii::app()->name ." | ". $value ;//这里看你的需求该
  }
}</code>
Copy after login

第三

在Controller中直接指定pageTitle:

<code>class YourController extends Controller {

    public $pageTitle = 'Your Title Here';
}    </code>
Copy after login

Happy Hacking

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template