Ask the question: What functions can the widget achieve?
Show Right post:
1, first create a new widget folder in the home directory, and then set up the corresponding file
2, take the hottest hot news For example:
The right.html file in the common public folder under the TPL directory is used to display the right post.
The tool code in which to write the top news :
Array End -To
All the code:
3, the corresponding HotWidget.class.php code:
<? PHP Class extends Widget { publicfunction render ($data) { $limit $data [' Limit ']; $data [' hot '] = M (' Blog ')->field (' id ', ' name ', ' click ')->order (' Clickdesc ')->limit ($limit) , Select (); return $this $data ); }}
4, the corresponding hot folder under the hot.html: code:
<dl> <dt> Top posts </dt> <foreach name= "hot" item= "V" > <dd > $v[' id '])}> "><{$v.title}></a> <span> (<{$v. click}>) </span> </dd> </foreach></dl>
Finish.
Thinkphp-widget Tools