Property "User.seo" is not defined Error

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.

Property "User.seo" is not defined Error

Postby Ashwini » 13 Aug 2015, 09:10

when i i write the following functions in \protected\models\User.php , " Property "User.seo" is not defined." error is occured.
i want to create , seo friendly url for , alllistings page with agency name., like users/alllistings/agency_name/

function :-

public function getLinkToAllListings($absolute = true)
{
if(issetModule('seo') && param('genFirendlyUrl')){
$seo = SeoFriendlyUrl::getForUrl($this->id, 'Apartment');

if($seo){
$field = 'url_'.Yii::app()->language;
return Yii::app()->createAbsoluteUrl('/apartments/main/alllistings', array(
'url' => $seo->$field . ( param('urlExtension') ? '.html' : '' ),
));
}
}

return Yii::app()->createAbsoluteUrl('/apartments/main/alllistings', array(

//'name' => $this->agency_name,
'id' => $this->id,
));
*/

if (issetModule('seo')) {
return $this->getRelationUrl1($absolute);
} else {
return self::getUrlById1($this->id, $absolute);
}
}

public function getRelationUrl1($absolute = true)
{
$method = $absolute ? 'createAbsoluteUrl' : 'createUrl';

if (issetModule('seo')) {
$seo = $this->seo;
if ($this->seo) {
$field = 'url_' . Yii::app()->language;
return Yii::app()->{$method}('/apartments/main/alllistings', array(
'url' => $seo->$field . (param('urlExtension') ? '.html' : ''),
));
}
}

return Yii::app()->{$method}('/apartments/main/alllistings', array(
'id' => $this->id,
));
}
Ashwini
Passer
 
Posts: 44
Joined: 03 Aug 2015, 12:41
Reputation point: 0

Re: Property "User.seo" is not defined Error

Postby Koduc » 14 Aug 2015, 12:21

Open file protected/models/User.php and insert line
Code: Select all
$relations['seo'] = array(self::HAS_ONE'SeoFriendlyUrl''model_id''on' => 'model_name="User"'); 

before
Code: Select all
return $relation
-- Меньше знаешь - крепче спишь --
User avatar
Koduc
Team lead
Team lead
 
Posts: 64
Joined: 28 Dec 2011, 09:11
Reputation point: 0


Return to Questions and help for changes

Who is online

Users browsing this forum: No registered users and 34 guests