What is "template" in CListView?

I am study Yii Blog demo, and feel it is insanely difficult for me.

What is the “template” of CListView in the below view code? I still couldn’t figure what it is and how it’s used after reading the class reference. Please help! Thank you!


<?php $this->widget('zii.widgets.CListView', array(

	'dataProvider'=>$dataProvider,

	'itemView'=>'_view',

	'template'=>"{items}\n{pager}", // here is the template that confused me!! 

)); ?>

Here is the _view.php, I didn’t find “template” is used here.


<div class="post">

	<div class="title">

		<table>

			<tr>

	    		<td class="span-2">

				<?php $this->widget('PostDate', array('ct'=>date('F'.'<\b\r>j', $data->create_time))); ?>

			</td>

			<td>&nbsp;<?php echo CHtml::link(CHtml::encode($data->title), $data->url); ?>

			</td>

			</tr>

		</table>

	</div>

	<div class="author">

		posted by <?php echo $data->author->username . ' on ' . date('F j, Y',$data->create_time); ?>

	</div>

	<div class="content">

		<?php

			$this->beginWidget('Markdown', array('purifyOutput'=>true));

			echo $data->content;

			$this->endWidget();

		?>

	</div>

	<div class="nav">

		<b>Tags:</b>

		<?php echo implode(', ', $data->tagLinks); ?>

		<br/>

		<?php echo CHtml::link('Permalink', $data->url); ?> |

		<?php echo CHtml::link("Comments ({$data->commentCount})",$data->url.'#comments'); ?> |

		Last updated on <?php echo date('F j, Y',$data->update_time); ?>

	</div>

</div>



Template is pre-formatted pattern to determine the way variables ‘items’ and ‘pager’ will be displayed.

For example if changed to "{pager}\n{items}\n{summary}" then the pager will be displayed above the posts, and a summary at the bottom of the page.

Thanks! This way of controlling element is a little bit confusing to me~

i have a question…

Can we make more complex templates with this… because i tried this


'template' => "<div>{summary}</div>{sorter}\n{items}\n{pager}",

and my summary block gets rendered inside that div.

so is it ok to make complex templates with this or there is better approach for this.

That’s just fine.