Next Previous Links On Detail Page

Hey all


I have a site which shows products.

When User Search it shows products in search page.

When user clicks on some product it goes to its detail page.


What i want when user goes to detail page …It should show 2 links …PREV and NEXT

so if i click on next next product should come and so on

I did some same functionality by putting products ids in some sessions but thats not looking fine to me…

Any suggestion?

Any Thoughts?

If some one did some same functionality Please let me know



hope this helps you :

$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");


	echo '<a href="index.php?r=produit/view&id='.$modelPrecedent->ProduitID.'><img src="images/previous.jpg" /></a>';


	echo '<a href="index.php?r=produit/view&id='.$modelSuivant->ProduitID.'><img src="images/next.jpg" /></a>';

And how to handle multiple search params ?

Should send them with query string when user will go to detail page?

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 :)