Yii Framework Forum: How can I solve global prefix for the page Title - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How can I solve global prefix for the page Title Would it have an automatic from main.php in view only set TITLE. Rate Topic: -----

#1 User is offline   sp__ 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 19-January 12

Posted 22 August 2012 - 05:34 AM

How can I solve global prefix for the page Title?
Would it have an automatic from main.php in view only set TITLE.

Something ala before render or something ...


main.php
..
'params' => array(
        'prefixPageTitle'=> 'My Application - ',
..


/view/account/index.php
$this->pageTitle = 'My Account';



I do not use
$this->pageTitle = Yii::app()->params['prefixPageTitle'].'My Account';


result: My Application - My Account

how-to ?



thank you
0

#2 User is offline   bennouna 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,166
  • Joined: 05-January 12
  • Location:Morocco

Posted 22 August 2012 - 05:42 AM

Hi,

You could define it in your protected/components/Controller.php for instance. I don't know if it's the best approach, but that's what I do.
0

#3 User is offline   CodeButterfly 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 51
  • Joined: 30-August 12

Posted 18 November 2012 - 05:55 AM

How about just put the prefix in your layout file? Either directly:

<title><?php echo CHtml::encode('My app - ' . $this->pageTitle); ?></title>


or using your parameter:

<title><?php echo CHtml::encode(Yii::app()->params['prefixPageTitle'] . $this->pageTitle); ?></title>

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users