Issues with CListVIew rendering

Today, I have past ‘literal’ hours trying to figure out how to customize my CListView generated ‘view’. I think there should be a view file with EXPLICIT CONTENTS INTO IT than i could have played with (i.e. <? php if(summarize): ?, that would be ease>). But no, instead i had “learnt” a sub-language of configuring widget classes (cssClasses), and templating attributes.

Perhaps you did that way to have thinner views, though it’d be nicer to have some tags generated behind the scenes … From designer (or front-end) point of view, life turns harder, as there is no have EXPLICIT no brainer control over render contents.

p.s. If anyone knows how to get rid of pager.css embed stylesheet, let me know, thanks.

This is what I propose:


<?php if($data->summary): ?>

    <div class="summary">Displaying <?php echo $data->summary->x; ?> of <?php echo $data->summary->n; ?> result(s).</div><!-- summary -->

<?php endif; ?>

<div id="items">

    <?php foreach($data->items as $item): ?>

        <div class="article">

            <h2><?php echo CHtml::link($item->title, $item->getUrl()); ?></a></h2>

            <?php echo nl2br($item->content); ?>

            <div class="info"><?php echo CHtml::link('read more', $$item->getUrl()); ?>

                <span> | By <?php echo $$item->author->username; ?>, on 

                <?php echo date('l, F j, Y', $$item->create_time); ?>.</span></div>

        </div><!-- item -->

    <? endforeach; ?>

</div><!-- items -->

<?php if($data->pager): ?>

    <div class="pager">

        Go to page:


            <li class="first hidden"><?php echo Chtml::link('someLink', '#'); ?></li>

            <li class="previous hidden"><?php echo Chtml::link($data->pager->previous['title'], $data->pager->previous['url']); ?></li>

            <li class="page selected"><?php echo Chtml::link($data->pager->selected['title'], $data->pager->selected['url']); ?></li>

            <li class="page"><?php echo Chtml::link($data->pager->page['x']['title'], $data->pager->page['x']['url']); ?></li>

            <li class="next"><?php echo Chtml::link($data->pager->next['title'], $data->pager->next['url']); ?></li>

            <li class="last"><?php echo Chtml::link($data->pager->last['title'], $data->pager->last['url']); ?></li>

        </ul><!-- or new CLinkPager(...); -->

    </div><!-- pager -->

<?php endif; ?>

A view that comprehensibly renders the widget. Using data send from it, in this case I used array data access, but it could be templated as well {pagerNextTitle}. This way everything is more clear, and manageable. No more configurations

CListView is the way it is so that it can be configured in all ways imaginable. It is far more flexible than a static view.

I would suggest that you look at all the components to it to see how you want to configure it. There is, of course, the itemview in which you can put all the code that you like for individual items (for example I often use ‘itemsTagName’ => ‘ul’ in the CListView configuration, and then put my data in an <li> in the itemview in order to generate a proper unordered list).

You’ll see that you can configure and extend how everything is displayed in one way or another through the configuration.

To get rid of the pager stylesheet, all you need to do is add the following to your CListView configuration:

                'pager' => array(

	                  'cssFile' => false,