Detail view options

Hi all,

I am new to the forum and have a few weeks of experience with Yii. I have tested with the tutorials. It seems to me CRUD delivers fine usable views… Sounds like a but coming up…

But, Is there a way in Detail view to directly access the first, previous, next, last db record, instead of having to go back to the list (index view)and select another detail from there.

So, to apply a kind of db navigation bar.

Hope anyone can help me…


Well, for there to be a next and a last, you need an order to navigate in. If there is a unique field that you could sort on, such-as the primary key, you could find the items with a greater or lesser primary key value respectively.

This should work:

$next = Table::model()->find(array(

	'condition'=>'TableID > ?',





$nextUrl = $this->createUrl('',array('id'=>$next->TableID));

$last = Table::model()->find(array(

	'condition'=>'TableID < ?',


	'order'=>'TableID DESC',



$lastUrl = $this->createUrl('',array('id'=>$last->TableID));

The ‘select’=> line restricts it to only retrieving the TableID, for the creation of the next and last URLs. If you want to pull the page name or any other information, you could add the desired fields or just remove those lines so it reverts to *.

Well thanks Lilt for your fast reply. I will try your code snippet