Yii 1.1: Prevent asset publishing for CListView

6 followers

If you don't want to use any of the AJAX features of CListView and thus want to prevent that it publishes any of its asset files, you can extend it and create a sub class like this:

<?php
Yii::import('zii.widgets.CListView');
/**
 * SimpleListView
 *
 * Custom CListView widget that does not publish any assets. They are only
 * required for AJAX enabled list views.
 */
class SimpleListView extends CListView
{
    /**
     * Override CListView::baseScriptUrl to prevent asset publishing in init()
     *
     * @var mixed URL of published assets. False prevents asset publishing.
     */
    public $baseScriptUrl=false;
 
    /**
     * Override CListView::cssFile to prevent CSS publishing
     *
     * @var mixed URL of published assets. False prevents asset publishing.
     */
    public $cssFile=false;
 
    /**
     * Override CListView::run() to prevent registration of client script.
     */
    public function run()
    {
        echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";
        $this->renderContent();
        echo CHtml::closeTag($this->tagName);
    }
}

Total 2 comments

#10191 report it
yiqing95 at 2012/10/10 03:22am
@ How about to set ajaxUpdate and cssFile

that's ok , but if you want apply this solution all the site . you 'd better use a subClass of CGridView/CListView .. . as this wike implemented !

#3626 report it
kazio at 2011/04/25 07:38am
ajaxUpdate and cssFile

How about to set ajaxUpdate and cssFile

Leave a comment

Please to leave your comment.