Prevent asset publishing for CListView

You are viewing revision #1 of this wiki article.
This is the latest version of this article.

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);
    }
}
2 0
6 followers
Viewed: 14 154 times
Version: Unknown (update)
Category: How-tos
Written by: Mike
Last updated by: Mike
Created on: Apr 20, 2011
Last updated: 12 years ago
Update Article

Revisions

View all history

Related Articles