$modelPrecedent = Produit::model()->findBySql("Select * from Produit where ProduitID < ".$model->ProduitID." Order By ProduitID desc");
$modelSuivant = Produit::model()->findBySql("Select * from Produit where ProduitID > ".$model->ProduitID." Order By ProduitID");
if($modelPrecedent!=null)
echo '<a href="index.php?r=produit/view&id='.$modelPrecedent->ProduitID.'><img src="images/previous.jpg" /></a>';
if($modelSuivant!=null)
echo '<a href="index.php?r=produit/view&id='.$modelSuivant->ProduitID.'><img src="images/next.jpg" /></a>';
I’m new to all this but in one of the demos apps, they show a private var that is used to pass info to other functions. Could that work?
Off the top of my head…
In Model:
class Model1 .....
{
...
private _prevId = null;
private _nextId = null;
...
public function afterFind()
{
//find/calculate/set $this->_prevId;
//find/calculate/set $this->_nextId;
}
public function getPrevId() {
return $this->prevId;
}
public function getNextId() {
return $this->nextId;
}
}
Check the code generated in the ViewDetal link and modify for the Prev/Net links in the _view file using $model(or $data)->prevId/nextId in the array(‘id’=>#) section.
I would think that would also keep the search params intact will "surfing."
If this doesn’t work, it might point you in a direction that does. Just tring to do my part