应用phpcms时遇到的问题及smarty标签的应用

1、循环语句{loop $data $n $r} {/loop}

 
  
// php对应源代码
<? php $data = subcat( $module , $catid ); ?>
<? php } ?>

【具体实例】

ContractedBlock.gif ExpandedBlockStart.gif 标签模板获取当前栏目名及提取栏目下的新闻
 
   
{loop $data $n $r }
{
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对应源代码
<? php $DATA = get( " sql语句 " , 0 , 0 , "" , "" ); if ( is_array ( $DATA )){ foreach ( $DATA AS $n => $r ) { $n ++ ; ?>
<? php } } unset ( $DATA ); ?>

【具体实例】

 
  
{get sql = " SELECT * FROM `xw_special_content` AS a, `xw_content` AS b WHERE a.contentid = b.contentid AND a.specialid = $specialid ORDER BY b.contentid DESC " rows = " 15 " }
// 内容
{ / get}

3、条件语句{if}{elseif}{else}{/if}

【具体实例】

ContractedBlock.gif ExpandedBlockStart.gif 通过判断设置前3调新闻数据不一样的样式
 
   
{ if $n < 4 }
< 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、一定用到的帮助文档及数据字典

PHPCMS2008 开发文档

转载于:https://www.cnblogs.com/cheche/archive/2010/06/03/1750982.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值