Fixing issues with indexing

Write about issues that you have found.

Moderators: Koduc, Xpycm

Forum rules
Pay attention! Forum is not a means for guaranteed support of clients and users. An answer as well as a quick answer is not supposed on the forum. We post messages as soon as possible.

The message limit on the forum is 3 messages per day.
If you want to say "thank you" then use the function "Give good reputation point", which is a green icon "plus" under the nickname of the person, who answered the message.

Fixing issues with indexing

Postby andipas » 10 Jun 2013, 15:30

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);
  
andipas
Web Developer
Web Developer
 
Posts: 156
Joined: 28 Dec 2011, 22:37
Reputation point: 1

Re: Fixing issues with indexing

Postby Xpycm » 10 Jun 2013, 15:38

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));
    }
}
  
Dropbox
Open Real Estate CMS: FAQ | FAQ 2 | FAQ 3
Image
Xpycm
Web Developer
Web Developer
 
Posts: 281
Joined: 30 Dec 2011, 11:06
Reputation point: 2

Re: Fixing issues with indexing

Postby Xpycm » 11 Jun 2013, 09:56

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).
Dropbox
Open Real Estate CMS: FAQ | FAQ 2 | FAQ 3
Image
Xpycm
Web Developer
Web Developer
 
Posts: 281
Joined: 30 Dec 2011, 11:06
Reputation point: 2


Return to Issues

Who is online

Users browsing this forum: Google [Bot] and 17 guests

cron