Url's friendly

Questions and answers about change of functions, design, hosting etc.

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.

Url's friendly

Postby Drubilar » 05 Dec 2012, 12:13

Hi, you know any way to transform URL like "property/45" to "{property type} / {page title}"?
Regards
Drubilar
Stranger
 
Posts: 8
Joined: 05 Dec 2012, 12:09
Reputation point: 0

Re: Url's friendly

Postby Xpycm » 05 Dec 2012, 14:23

сonfig/main.php file
in the section 'rules' comment the line:
Code: Select all
property/<id:\d+>'=>'apartments/main/view',


protected/modules/apartments/models/Apartment.php file
instead of:
Code: Select all
public function getUrl() {
    //$tmp = 'title_'.Yii::app()->language;
    return Yii::app()->createUrl('/apartments/main/view', array(
        'id' => $this->id,
        //'title' => $this->$tmp,
    ));
}
 


write:
Code: Select all
public function getUrl() {
    $tmp = 'title_'.Yii::app()->language;

    return Yii::app()->createUrl('/apartments/main/view', array(
        'id' => $this->id,
        'title' => $this->$tmp,
        'propertyType' => $this->objType->name_en,
    ));
}
 


protected/components/CustomUrlManager.php file
to add the method init() before parseMyInitRules() method:
Code: Select all
public function init(){
    $this->_myRules = array(
        array(
            'replace' => array(
                '<title:.*?>',
                '<id:\d+>',
                '<propertyType:.*?>',
            ),
            'route' => 'apartments/main/view',
            'pattern' => param('module_apartments_apartmentSeoPattern', '::text/::title-::id.htm'),
            'model' => 'Apartment',
            'path' => 'application.modules.apartments.models.Apartment',
            'seo_text' => 'apartments',
        ),
    );
    $this->parseMyInitRules();
    parent::init();
}
 


and instead of:
Code: Select all
public function parseMyRules($params, $ampersand)
{
    if (!$this->_myRules) {
        return;
    }
    if (isset($params['id']) && isset($params['title'])) {
        foreach ($this->_myRules as $rule) {
            if (Yii::app()->controller->route == $rule['route']) {
                if ($this->_replaceSymb) {
                    $params['title'] = str_replace($this->_replaceSymb, '-', $params['title']);
                }
            }
        }
    }
    return false;
}
 


it is needed:
Code: Select all
public function parseMyRules($params, $ampersand)
    {
    if (!$this->_myRules) {
        return;
    }
    if (isset($params['id']) && isset($params['title'])) {
        foreach ($this->_myRules as $rule) {
            if (Yii::app()->controller->route == $rule['route']) {
                if ($this->_replaceSymb) {
                    $params['title'] = str_replace($this->_replaceSymb, '-', $params['title']);
                }

                $title = CHtml::encode($params['title']);
                $id = $params['id'];

                $seoPattern = $this->parseMyLink(array(
                    $title,
                    $id,
                    $rule['seo_text'],
                ), $rule['pattern']);

                if($seoPattern){
                    return parent::createUrl('/'.$seoPattern, array(), $ampersand);
                }
            }
        }
    }
    return false;
}
 


protected/modules/viewallonmap/components/ViewallonmapWidget.php file
after:
Code: Select all
$criteria = new CDbCriteria; 


write:
Code: Select all
$criteria->with = array('objType'); 


I have described to you everything that our forum allows.

At forum we do not help for more global changes in the code.
You can send us the list of changes that you need via a contact form http://monoray.net/contact.
We evaluate it and say you the price.
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: Url's friendly

Postby Drubilar » 11 Dec 2012, 14:39

work!, thank you very much *BRAVO*
The only observation I make is the URL from the map, here the URL takes the name of the category "apartment" instead of the corresponding.
Example:

from the list:
/Terreno/Terreno-para-constructora-41.htm

from the map link:
/apartments/Terreno-para-constructora-41.htm
Drubilar
Stranger
 
Posts: 8
Joined: 05 Dec 2012, 12:09
Reputation point: 0

Re: Url's friendly

Postby Xpycm » 12 Dec 2012, 07:34

Drubilar wrote:
The only observation I make is the URL from the map, here the URL takes the name of the category "apartment" instead of the corresponding.
Example:

from the list:
/Terreno/Terreno-para-constructora-41.htm

from the map link:
/apartments/Terreno-para-constructora-41.htm


Welcome :-)

From the page "Mapa de Propiedades" link is "/Terreno/Terreno-para-constructora-41.htm". Screenshot - https://www.dropbox.com/s/pqcsexvpzixy5 ... 082723.png
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: Url's friendly

Postby Xpycm » 12 Dec 2012, 09:07

Please try clear site cache - viewtopic.php?f=17&t=297
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 Questions and help for changes

Who is online

Users browsing this forum: No registered users and 1 guest

cron