Page 1 of 1

Fixing issues with indexing

PostPosted: 10 Jun 2013, 15:30
by andipas
A possible cause of pages' missing in the index is canonical links. They are used in the product to prevent pages with duplicate content from indexing.

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);
  

Re: Fixing issues with indexing

PostPosted: 10 Jun 2013, 15:38
by Xpycm
Fixes for a free ORE, version 1.3.3:

Remove in the protected\modules\apartments\helpers\apartmentsHelper.php file
the code:
Code: Select all
if(Yii::app()->getRequest('sort') || Yii::app()->getRequest('page')){
    $href = Yii::app()->getBaseUrl(true).'/'.Yii::app()->request->getPathInfo();
    Yii::app()->clientScript->registerLinkTag('canonical', null, $href);
    unset($href);
}
  


In the protected\modules\quicksearch\controllers\MainController.php file
add in the beginning of the actionIndex() method (before $criteria = new CDbCriteria;) and in the beginning of actionMainsearch() method (before $criteria = new CDbCriteria;)
the code:
Code: Select all
$href = Yii::app()->getBaseUrl(true).'/'.Yii::app()->request->getPathInfo();
Yii::app()->clientScript->registerLinkTag('canonical', null, $href);
unset(
$href);  


Fixes for a paid ORE, version 1.3.3:
Besides the mentioned above actions (fixes for a free version) you should add in the actionIndex() method of the protected\controllers\SiteController.php file the code:
Code: Select all
if(!isset($_GET['lang'])){
    $canonicalUrl = Yii::app()->getBaseUrl(true);

    $canonicalUrl .= '/'.Yii::app()->language;
    Yii::app()->clientScript->registerLinkTag('canonical', null, $canonicalUrl);
    unset($canonicalUrl);
}
  


So you will get as a result the following:
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(!isset($_GET['lang'])){
        $canonicalUrl = Yii::app()->getBaseUrl(true);

        $canonicalUrl .= '/'.Yii::app()->language;
        Yii::app()->clientScript->registerLinkTag('canonical', null, $canonicalUrl);
        unset($canonicalUrl);
    }
    
    if 
(isset($_POST['is_ajax'])) {
        $this->renderPartial('index', array('page' => $page), false, true);
    } else {
        $this->render('index', array('page' => $page));
    }
}
  

Re: Fixing issues with indexing

PostPosted: 11 Jun 2013, 09:56
by Xpycm
Fixing a problem with canonical links.

For version 1.4.3 (free and paid ones) - http://static.monoray.net/_fix_canonica ... -06-11.zip
For version 1.3.3 (a free version) - http://static.monoray.net/_fix_canonica ... -06-11.zip

Download the zip file and replace the files from it.

Before changing the old files for the new ones we recommend you to save the old copies of files (make a backup).