Let's try to remove them from the home page and from pages of listings' viewing.
Change in the /protected/controllers/SiteController.php file the code:
- Code: Select all
$canonicalUrl = Yii::app()->getBaseUrl(true);
if(!isFree()){
$canonicalUrl .= '/'.Yii::app()->language;
}
Yii::app()->clientScript->registerLinkTag('canonical', null, $canonicalUrl);
$this->alreadyTagCanonical = true;
for
- Code: Select all
if(!isFree() && !isset($_GET['lang'])){
$canonicalUrl = Yii::app()->getBaseUrl(true);
$canonicalUrl .= '/'.Yii::app()->language;
Yii::app()->clientScript->registerLinkTag('canonical', null, $canonicalUrl);
}
So we will have as a result:
- Code: Select all
public function actionIndex() {
//$dependency = new CDbCacheDependency('SELECT date_updated FROM {{menu}} WHERE id = "1"');
$page = Menu::model()->/* cache(param('cachingTime', 1209600), $dependency)-> */findByPk(1);
if(!isFree() && !isset($_GET['lang'])){
$canonicalUrl = Yii::app()->getBaseUrl(true);
$canonicalUrl .= '/'.Yii::app()->language;
Yii::app()->clientScript->registerLinkTag('canonical', null, $canonicalUrl);
}
if (isset($_POST['is_ajax'])) {
$this->renderPartial('index', array('page' => $page), false, true);
} else {
$this->render('index', array('page' => $page));
}
}
Remove in the /protected/modules/apartments/controllers/MainController.php file
the code:
- Code: Select all
Yii::app()->clientScript->registerLinkTag('canonical', null, $apartment->getUrl());
$this->alreadyTagCanonical = true;
Remove in the /protected/modules/menumanager/controllers/MainController.php
the code:
- Code: Select all
Yii::app()->clientScript->registerLinkTag('canonical', null, $model->getUrl());
$this->alreadyTagCanonical = true;
Remove in the /protected/components/Controller.php
the code:
- Code: Select all
public $alreadyTagCanonical = false;
Remove in the /protected/modules/apartments/helpers/apartmentsHelper.php
the code:
- Code: Select all
if(Yii::app()->getRequest('sort') || Yii::app()->getRequest('page')){
if (!Yii::app()->controller->alreadyTagCanonical) {
$href = Yii::app()->getBaseUrl(true).'/'.Yii::app()->request->getPathInfo();
Yii::app()->clientScript->registerLinkTag('canonical', null, $href);
unset($href);
}
}
Add the following code in the 'public function actionIndex' method and in the 'public function actionMainsearch' method of the /protected/modules/quicksearch/controllers/MainController.php file:
- Code: Select all
$href = Yii::app()->getBaseUrl(true).'/'.Yii::app()->request->getPathInfo();
Yii::app()->clientScript->registerLinkTag('canonical', null, $href);
unset($href);