Replace Meta-Tag

Not all pages should have a "index,follow" as robots meta tag, so I wanted to replace it in some views like this:


Yii::app()->clientScript->registerMetaTag('noindex,noarchive','robots');

But this way an additional robots meta tag is is inserted below the "original" instead of replacing the "original".

The "original" can be found in the /views/layouts/main.php as follows:


<?php echo CHtml::metaTag('index,follow', 'robots') ?>

So I hoped/thought it would be recognized.

Could please anybody help me?

Thank you.

Check out this cookbook. Then you can set meta tags per action




class MyController extends ParentController

{


   public function actionIndex()

   {


      $this->pageNoIndex = true;


      ...


   }


}



or per controller




class MyController extends ParentController

{


   public $pageNoIndex = true;


   public function actionIndex()

   {


      ...


   }


}



If you need help let me know.

Thank you for your advice, Y!!.

I already read this cookbook entry and in my opinion it’s not a really clean way to manage this, but as it seems, there’s no other alternative to solve this. The word “register” in registerMetaTag sounds for me like a “central meta-tags”-register.

Due to some meta tags unique nature (language, robots, author, copyright, …) it would be no big deal to override a already set meta tag from the controller or view.

Anyway thank your very much and now I’ll explore the rest ;)

The old post, but I am wandering if the following is much easier:

In main.php I have params ‘keyWords’ and ‘description’ with default values for the application.


//I can set any value in action or controller by modifying the above params:

Yii::app()->params['keyWords']='new key word';

Yii::app()->params['description']='new description';


//in layouts I have:

<meta name="Keywords" content="<?php echo Yii::app()->params['keyWords']; ?>">

<meta name="Description" content="<?php echo Yii::app()->params['description']; ?>">