Customize title

Hi all,

How to customize the tag <title> in Yii2 as before in Yii1




   // Custom <title> Yii1

   $this->pageTitle = "my custom title";



Try in Yii2




class SiteController extends Controller

{

   public $title;

   public function actionAbout()

   {

       $this->title=Yii::$app->name . " - My Custom title";

       return $this->render('about');

   }

}



index.php




<!DOCTYPE html>

<html lang="<?php echo Yii::$app->language;?>">

<title><?php echo Html::encode($this->title);?></title>

<head>

...

...

</html>



But not working.

Thanks!

$title is the view property now so in controller use $this->getView()->title.

Thanks!

Also in view




<?php

   // FILE: \_Local\server\root\yii2\views\site\about.php


   $this->title = 'About Us';


   // Here content VIEW

   ...

   ...

?>

[size=“3”]Problem resolved![/size] :D