Accessing The 'name' Property From The Config And Best Practice For Altering Page Titles

Hi folks,

I am having an issue where I want to be able to echo out the project name, as per ‘name’=>‘The Project Name’ in the main.php config file.

The reason I want to be able to access this is that I wish to use it in the copyright info in the footer and I also want to be able to have an application that requests information from the database about a certain item for sale and pull back from the db the string to be appended to the application name so I can have something like this…

<title>The application name from the main config file here | the additional title information from the database appended here</title>

Is this possible?

Thanks in advance.

// in you  main layout file ;

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

// then  in you components/Cotroller.php file:

   public $pageTitle = '';


because most controller will extends the Controller base class . so you can access

pageTitle in subclass of Cotroller . and assign it any string you want . normally in you action methed :

   public function actionView($id){

         $model = XX::model()->findByPk($id);

         $this->pageTitle = 'anyString here';  // or use $this->pageTitle = $model->name ; ..



see my wiki here :pass variables or content block from view file to layout file

Excellent! Thank you!