Page 1 of 1

Property "User.seo" is not defined Error

PostPosted: 13 Aug 2015, 09:10
by Ashwini
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,
));
}

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

PostPosted: 14 Aug 2015, 12:21
by Koduc
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