我试图用CListView生成RSS页面,但是我在结果中得到了其他生成的html:

<div id="yw0" class="list-view">
<div class="items">


<div class="keys" style="display:none" title="/index.php/rss"><span>2383</span><span>4743</span><span>1421</span></div>

我该如何删除?

最佳答案

不更改CListView类(yii v.1.1.8),就无法做到这一点。

CListView扩展了CBaseListView
http://code.google.com/p/yii/source/browse/tags/1.1.8/framework/zii/widgets/CBaseListView.php

    /**
     * Renders the view.
     * This is the main entry of the whole view rendering.
     * Child classes should mainly override {@link renderContent} method.
     */
    public function run()
    {
            $this->registerClientScript();

            echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";

            $this->renderContent();
            $this->renderKeys();

            echo CHtml::closeTag($this->tagName);
    }

    /**
     * Renders the key values of the data in a hidden tag.
     */
    public function renderKeys()
    {
            echo CHtml::openTag('div',array(
                    'class'=>'keys',
                    'style'=>'display:none',
                    'title'=>Yii::app()->getRequest()->getUrl(),
            ));
            foreach($this->dataProvider->getKeys() as $key)
                    echo "<span>".CHtml::encode($key)."</span>";
            echo "</div>\n";
    }

10-08 07:00