3

重要なのは、CListViewレンダリングからこれらの2つのdivを削除することです。

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

私はここを見てきました:

https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/CBaseListView.php#L123

しかし、私はそこにそれらの2つのdivに関連するものは何も見つかりませんでした。

誰かが共有できますか、これを実現するために何を拡張する必要がありますか?

必要な出力の更新は次のとおりです。

<div>
  <article class="itemthing">
    list data
  </article>
  <article class="itemthing">
    list data
  </article>
  <article class="itemthing">
    list data
  </article>
</div>
4

1 に答える 1

2

CListView自体から拡張する方がよいでしょうが、 CBaseListViewのメソッドの新しい実装と、run() CListViewのメソッドrenderItems() 新しい実装を記述します。次に例を示します。

Yii::import('zii.widgets.CListView');
class MListView extends CListView{
    public function run(){
            $this->registerClientScript();
            // this line renders the first div
            //echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n"; 

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

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

    public function renderItems(){
            //this line renders the second div
            //echo CHtml::openTag($this->itemsTagName,array('class'=>$this->itemsCssClass))."\n"; 
            // copy original code from the function
            //echo CHtml::closeTag($this->itemsTagName);
    }
}

編集:

jquery.yiilistview.jsは、このリストビューを識別するIDがないと機能しないため、デフォルトのclistview機能の一部はこれだけでは機能しないことに注意してください。

編集:

更新された質問から、これを行うことができます。

<div id="some-id">
<?php
    $this->widget('ext.extendedwidgets.MListView',array(
        'id'=>'some-id', // same id you specified in the div
        //... rest of it
        'template' => '{items}', // as seen in the chat below
    ));
</div>
于 2012-09-06T11:18:42.963 に答える