Change the title on browser tab

[color=#333333][font=sans-serif][size=2]I am looking for a way to change the title that shows up on the browser tab on our website. like [/size][/font][/color][font="sans-serif"][color="#333333"][size=2]http://localhost/~user/demo/web/index.php?r=site into InvoiceMangement. is it possible in yii2 ? [/size][/color][/font]

thanks :)

Of course is it possible.

app/views/layout/main.php

Between the <head></head> tags.




// change $this->title to whatever you want as title

<title><?= Html::encode($this->title) ?></title>



Regards

In the view file you’ll see something like :


$this->title = 'About';

This sets the browser windows title (or tab title) to ‘About’.

ciao

B)

thank guys it worked :)

If you need the name of the app to be there (and just change the second part of the title, so the action name):

In your controller (override the setPageTitle method):




public function setPageTitle($value){

		$this->pageTitle=Yii::app()->name." - ".$value;

	}



and then set the title in each Action, example:




public function actionCreate()

	{

		$this->pageTitle = "New Title";

...

...

...



The result will be:

App Name - New Title