nachiket
(Patel Nachiket R)
June 27, 2012, 2:55pm
1
I am new to Yii.
And I am trying to get multilingual-behavior work for my website.
I am able to make it work for view/edit pages of model by modifying loadModel() method.
But I am not able to make it work for Index/Manage (list) pages pages.
Following is my code in index() method. It is loading default contents only.
$aboutus = new Aboutus();
$criteria=new CDbCriteria;
$criteria->condition='deleted=0';
$localizedCriteria = $aboutus->ml->modifySearchCriteria($criteria);
$dataProvider=new CActiveDataProvider('Aboutus', array(
'criteria'=>$localizedCriteria));
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
Any guidance/ pointer or solution are welcome. Thanks.
yugenekr
(Yugenekr)
June 28, 2012, 2:38am
2
Hi,
Never used this extension, but looked through its docs a bit and I’d start with these questions:
do you use defaultScope() as it is stated in docs?
what is your working code?
Regarding notice in docs:
I’d debug extension code to understand what’s going on when you apply criteria modification.
Regards,
Yuga
yugenekr
(Yugenekr)
June 28, 2012, 1:41pm
4
Nachiket:
working code? what do you mean? a full project?
okay, will try that.
Hi,
working code:
So I meant working implementation in loadModel().
But I think the best is to start with extension code debugging (relevant method(s)), especially having this vague notice at docs.
fredpeaks
(Frederic Rocheron)
June 28, 2012, 6:23pm
5
Hi, I think you don’t have to use “$localizedCriteria = $aboutus->ml->modifySearchCriteria($criteria);” to localize criteria cause the “deleted” attribute doesn’t seem to be translated.
You can directly use your $criteria object.
If this doesn’t work, maybe the way you define the condition is not right.
Try: “$criteria->compare(‘deleted’,0);”
Hope this helps.
Regards,
Fred
Nachiket:
I am new to Yii.
And I am trying to get multilingual-behavior work for my website.
I am able to make it work for view/edit pages of model by modifying loadModel() method.
But I am not able to make it work for Index/Manage (list) pages pages.
Following is my code in index() method. It is loading default contents only.
$aboutus = new Aboutus();
$criteria=new CDbCriteria;
$criteria->condition='deleted=0';
$localizedCriteria = $aboutus->ml->modifySearchCriteria($criteria);
$dataProvider=new CActiveDataProvider('Aboutus', array(
'criteria'=>$localizedCriteria));
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
Any guidance/ pointer or solution are welcome. Thanks.
nachiket
(Patel Nachiket R)
June 29, 2012, 8:36am
6
fredpeaks:
Hi, I think you don’t have to use “$localizedCriteria = $aboutus->ml->modifySearchCriteria($criteria);” to localize criteria cause the “deleted” attribute doesn’t seem to be translated.
You can directly use your $criteria object.
If this doesn’t work, maybe the way you define the condition is not right.
Try: “$criteria->compare(‘deleted’,0);”
Hope this helps.
Regards,
Fred
Hi Fred,
What do you mean? can you please provide example?
Thanks