My next ‘mission’ is to explore the CContentDecorator class. I think this might be useful for wrapping album/image thumbnails within a ‘sub-view’. And this is definitely a better approach than using renderPartial.
This class may be useful to you. I am also building a gallery related application and extended CListView to show the list items (in my case, thumbnails) in a grid view.
I have CSS stuff hard coded into it at this point because it’s just a prototype, but take it if it’s any use to you.
Yii::import('zii.widgets.CListView');
class GalleryView extends CListView
{
/**
* @var int the number of columns to render in the table
* Defaults to 5
*/
public $cols = 5;
/**
* Renders the data item list.
*/
public function renderItems()
{
// hack to override Yii's default of alternating table row colors. Should be moved to a css file with other proper formatting.
//echo '<style type="text/css">tbody tr:nth-child(even) td, tbody tr.even td {background:#FFF;}</style>';
echo '<style type="text/css">
.GalleryView {background: silver; border-spacing: 2px;}
.GalleryView tbody tr td {background: #919AA9;}
</style>';
echo '<table border="0" cellspacing="1" cellpadding="0" width="100%" class="GalleryView">'."\n\t<tr>\n";
$data=$this->dataProvider->getData();
if(count($data)>0)
{
$owner=$this->getOwner();
$render=$owner instanceof CController ? 'renderPartial' : 'render';
$width = (100 / $this->cols).'%';
foreach($data as $i=>$item)
{
$data=$this->viewData;
$data['index']=$i;
$data['data']=$item;
$data['widget']=$this;
if($i % $this->cols == 0 && $i != 0)
echo " </tr>\n <tr>\n";
echo "\t\t<td class='thumb_square' id='thumb_square_$i' width='$width'>\n";
$owner->$render($this->itemView,$data);
echo "\n\t\t</td>\n";
}
}
else
$this->renderEmptyText();
echo "\n\t</tr>\n</table>\n";
}
}
I was thinking maybe it would be better to derive from CJuiSortable so that images are drag-drop re-organizable. Or maybe try scriptaculous. It does some of the things better than JQuery.
i v used it in my project , use it just like CListView , you should do something different to usual _view.php file, make this file as a album show element :