Body
Body

Reputation: 3688

Yii CListView - Adding a manual item

I'm using YiiBoostrap in my Yii app and I have a TbListView output some images.

<?php
        $this->widget('bootstrap.widgets.TbListView',array(
            'dataProvider'=>$dataProviderModerator,
            'id'=>'website-grid',
            'itemView'=>'_viewWebsite',
            'template'=>'{items}',
            'itemsCssClass'=>'grid-group row m-t-25',
            'cssFile'=>false,
            'summaryText'=>false,
            'pager'=>array(
                'header'=>'',
                'cssFile'=>false,
                'maxButtonCount'=>10,
                'selectedPageCssClass'=>'active',
                'hiddenPageCssClass'=>'disabled',
                'prevPageLabel'=>'&lsaquo;',
                'nextPageLabel'=>'&rsaquo;',
            ),
            'htmlOptions'=>array('class'=>'')));
?>

Output

enter image description here

I would like to add a div manually to the end of above generated lists, which I'm expecting something like this

enter image description here

How can I do this?

Upvotes: 1

Views: 286

Answers (2)

Maug Lee
Maug Lee

Reputation: 915

You can modify your 'template'=>'{items}', property by adding custom HTML with element:

'template'=>'{items}<div id="my_custom_element">Foo bar</div>',

or the same in more „elegant“ way:

// regarding your 'itemView'=>'_viewWebsite'
$item = $this->renderPartial('_viewWebsite', array(
    'your' => 'custom',
    'vari' => 'ables',
));

and

'template'=>'{items}'.$item,

Upvotes: 1

Maug Lee
Maug Lee

Reputation: 915

It must be possible with jQuery:

$('<div id="my_new_element">HUGE PLUS SIGN with all functionality</div>')
    .appendTo('#website-grid');

You can put this inside some JavaScript function and call it when needed. E.g. at first time or afterAjaxUpdate in your TbListView. This is just an idea. See how create DOM element and CListView::afterAjaxUpdate().

Upvotes: 0

Related Questions