Own Widget Insight Clistview

Hi,

I display an search result with the default CListView Widget:


$this->widget('zii.widgets.CListView',

                        array(

                            'dataProvider' => $dataProvider,

                            'itemView' => $view,

                            'ajaxUpdate' => false,

                            'template' => '{summary}{pager}<div class="cb spacer-line w99"></div>

                                                {items}

                                            <div class="cb"></div>{pager}',

                            'summaryText' => 'Found: {count} Docs',

                            'pager' => array(

                                'cssFile' => false,

                                'maxButtonCount' => 5,

                                'header' => '',

                                'prevPageLabel' => '«',

                                'nextPageLabel' => '»',

                                'htmlOptions' => array('data-statistik-item' => 'pagination')),

                        ));

If there are many hits, the pagination buttons appears on top and end of the CListView. This works fine, until now.

Before that problem occurs, the html file of the view only contains a mix from HTML and PHP to output the data.

The new thing is: in some cases I need to render an widget insight that itemView.


 <?php if (isset($data->url)): ?>

      <span style="display:none">

            <?php 

                  $this->widget('application.widgets.videoPlayerWidget',

                                 array('playerID'=>'vP'.$data->ID,

                                        url'=>$data->url));

                                    ?>

        </span>

 <?php endif;?>

Now:

If the CListView contains an item with an widget, the pager at the footer-section is broken (only {PAGER} displays), while the pager at the top sections is working correctly.

This happens in every case, even if the widget run-block contains no PHP-code.

Any idea how to debug that problem??

Thank you, rall0r.

While investigating that problem I found out, that this problem comes from the Yii command:


CHttpRequest::getBrowser();

If that is part of an CListView - Item View, the pager at the end of the CListView is not displayed.

It looks like, that calling this method breaks the CListView widget!

Can anybody confirm that behaviour?

In this case it looks like a bug in Yii??

//Edit: Okay, next Update. The problem is get_browser, what used the file browsercap.ini to find out the current client/browser. This file is an large on (650kB). So if an CListView contains (for example) 25 elements and insight each element there is an if-statements depends on the browser/client, so that file seams to be processed 25 (n-)times, which results in some broken scripts…

Hi rall0r,

Did you check the HTML output of the page?

It’s just a guess, but I suspect that your videoPlayerWidget might have an unmatched HTML tag … an opening tag without the corresponding closing tag, or a closing tag without the corresponding opening tag.

Hi softark,

as I wrote on my 2nd post, the reason was the CHttpRequest::getBrowser(); method, which was called multiple times. I have created my own getBrowser method, which called the CHttpRequest::getBrowser(); one time and cached the result.

So if you have an CListView with (for example) 25 items, which should be displayed depending on the browser version, there is now finally only one real CHttpRequest::getBrowser(); request and 24 times of cache access.

So the problem was solved.