1、循环语句{loop $data $n $r} {/loop}
<? php $data = subcat( $module , $catid ); ?>
<? php } ?>
【具体实例】
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
{ if $n == 1 }
< h3 >< a href = " { $CATEGORY [ $r [catid]][url]} " > { $CATEGORY [ $r [catid]][catname]} </ a ></ h3 >
< dl >
< dt >< a href = " { $r [url]} " target = " { $target } " >< img src = " {thumb( $r [thumb], $width , $height )} " alt = " { $r [title]} " width = " { $width } " height = " { $height } " /></ a ></ dt >
< dd >< a href = " # " >< a href = " { $r [url]} " target = " { $target } " title = " { $r [title]} " > {str_cut( $r [title] , $titlelen1 , '' )} </ a ></ a ></ dd >
</ dl >
< ul id = " aRightList " >
{ else }
< li >< a href = " { $r [url]} " target = " _bank " title = " { $r [title]} " >& bull;{str_cut( $r [title] , $titlelen2 , '' )} </ a ></ li >
{ / if }
{ / loop}
</ ul >
2、get循环语句{get sql="" rows=""}{/get}
<? php } } unset ( $DATA ); ?>
【具体实例】
// 内容
{ / get}
3、条件语句{if}{elseif}{else}{/if}
【具体实例】
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
< h2 >< a href = " { $r [url]} " target = " _blank " title = " { $r [title]} " > {str_cut( $r [title] , 48 , '' )} </ a ></ h2 >
{ elseif $n == 4 }
< ul class = " fix " >
< li >& bull; < a href = " { $r [url]} " target = " _blank " title = " { $r [title]} " > {str_cut( $r [title] , 48 , '' )} </ a ></ li >
{ else }
< li >& bull; < a href = " { $r [url]} " target = " _blank " title = " { $r [title]} " > {str_cut( $r [title] , 48 , '' )} </ a ></ li >
{ / if }
4、经常用到的sql语句
【循环提取栏目】:
select * from xw_category where parentid=32 and ismenu!='0' order by listorder asc
【循环提取某个栏目id=132下从第3条到第6条的新闻内容】:
select * from xw_content where catid=132 order by updatetime asc limit 3,6
【循环最热新闻(按点击率排行)】:
select c.contentid,c.catid,c.typeid,c.areaid,c.title,c.style,c.thumb,c.keywords,c.description,c.userid,c.updatetime,c.inputtime,c.url,n.hits form `phpcms_content` c,`phpcms_content_count` n where c.contentid=n.contentid and c.`status`=99 ".get_sql_catid(31)." order by n.hits desc
5、常用的数据语句
【文字链接】:
<a href="{$r[url]}" title="{$r[title]}">{str_cut($r[title], 40,'')}</a>
{str_cut($r[title], 40,'..')}: 第二次参数为截取的文字字节长度也就是可以写20个汉字,第三个参数为省略后的内容,不写者没有。
【缩略图链接】:
<a href="{$r[url]}"><img src="{thumb($r[thumb], 450, 351)}" alt="{$r[title]}" /></a>
{thumb($r[thumb], 450, 351)}第一个参数为基本图片数据,后两个参数为将要裁 剪的图片width和height,都是按等比例裁剪
【文章描述】:
<a href="{$CATEGORY[$r[catid]][url]}">[{$CATEGORY[$r[catid]][catname]}]</a>
{str_cut(strip_tags($r[description]),450)}第一个参数为基本数据,第二个参数为截取的长度值
【文章栏目名】:
<a href="{$CATEGORY[$r[catid]][url]}">[{$CATEGORY[$r[catid]][catname]}]</a>
6、一定用到的帮助文档及数据字典