ajith
(Ajith Tejas)
April 18, 2015, 12:19pm
1
[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
Raoul
(Manu34)
April 18, 2015, 9:27pm
3
In the view file you’ll see something like :
$this->title = 'About';
This sets the browser windows title (or tab title) to ‘About’.
ciao
erand
(Erandbraho)
September 7, 2015, 11:16am
5
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
onizuka
(onizuka)
September 6, 2024, 4:52am
6
Edit file index.php which reside in /views/site/
Change this code :
<?php
/* @var $this yii\web\View */
use yii\helpers\Html;
use app\assets\PkdAsset;
$this->title = 'InvoiceMangement';
?>
Refresh and reload page