I want to ask how can I change the layout of the standard CListView so it displays items in two columns.
The CSS solution with float is not the case here because I want to have irregular item height and with CSS float each item’s top line is kinda vertically aligned with the adjoined item’s top line.
Is there any solution better than just modyfying actual widget code?
Sorry for eventually bad english, it’s not my national language.
( Any tips according to english syntax would be awesome )
Well, just by editing the renderItems() method from CListView.php file in zii/widgets.
Or by making a new class derived from CListView.
Yes, I know that, but you see, CListView renders items in a single column ( by default it is "div" container with "items" class ) and what I want to achieve is to make it render half of the items encapsulated in another div.
Well, that’s pretty obvious
I’m not a newbie webmaster, just new to Yii framework
It does not? So what these statements do in the renderItems() method in CListView class:
public function renderItems()
{
echo CHtml::openTag($this->itemsTagName,array('class'=>$this->itemsCssClass))."\n";
...
echo CHtml::closeTag($this->itemsTagName);
}
This is the behaviour I wanted to change. The above code by default encapsulates all separate items ( which view file is the _view.php file you mentioned ) with a {itemsTagName} with {itemsCssClass}.
By modifying _view.php file ( name of the file can be changed through itemView property ) we are changing the view of the item, not the whole list.
For example if I had a list consisting of 6 elements, and put "<div class="test"></div>" in that file, I would get:
The $index variable is by default available in the item view file and contains the numerical index of the current rendered item ( I mean it counts the elements on each page from the beginning ) so the code is correct for every page.
Any reason why to send the $dataProvider->getItemCount() separately… as you are already sending the $dataProvider… in the view you can have something like