phpcms调用标签
2013-08-09 16:20:52 来源: 浏览: 次
导读:<!--调用HTML模版-->{template "content","header"}<!--调用seo标题、调用关键词、描述--><title>{if isset($SEO[title]) && !empty($S
<!--调用HTML模版-->
{template "content","header"}
<!--调用seo标题、调用关键词、描述-->
<title>{if isset($SEO[title]) && !empty($SEO[title])}{$SEO[title]}{/if}{$SEO[site_title]}</title>
<meta name="keywords" content="{$SEO[keyword]}">
<meta name="description" content="{$SEO[description]}">
<!--调用站点ID-->
{get_siteid()}
<!--目录调用css、js、img-->
{CSS_PATH}:地址替换为根目录下\statics\css
{JS_PATH}:地址替换为根目录下\statics\js
{IMG_PATH}:地址替换为根目录下\statics\img
<!--每当列表几行的时候出现一次这个-->
{if $num%2==0} {/if}
<!--调用栏目最新文章-->
{pc:content action="lists" catid="$catid" moreinfo="1" thumb="1" order="id DESC" num="10" cache="3600" page="$page"}
{loop $data $r}
<a href="{$r[url]}" target="_blank" title="{$r[title]}">{$r[title]}</a>
{/loop}
{/pc}
连接:<a href="{$r[url]}">{$r[title]}</a>
缩略图:{thumb($r[thumb],100,100)}
来源:{$r[copyfrom]}
摘要:{$r[description]}
更新时间:{$r[updatetime]}
发布时间:{$r[inputtime]}
内容:{$r[content]}
用户名:{$r[username]}
类别:{$r[typeid]}
截取字符串长度:{str_cut($r[title],20,'...')}
moreinfo="1"在推荐位中用不了,可用sql语句代替)
列表可用参数
action="hits" 排行,热点等
action="lists" 主要用于列表等。
<!--数据调用代码-->
{pc:content action="lists" catid="66" moreinfo="1" order="listorder ASC" num="99"}
{loop $data $r}
<li><a href="{$r[link]}"{if $r[isblank]==1} target="_blank"{/if}><img src="{$r[thumb]}"><span>{$r[title]}</span></a></li>
{/loop}
{/pc}
连接地址:link
isblak:是|1、否|2
<!--网站信息-->
网站首页----------------{siteurl($siteid)}
当前位置----------------{catpos($catid)}
栏目名称----------------{$CAT[catname]}
栏目拼音----------------{$CAT[letter]}
栏目链接----------------{$CAT[url]}
父栏目名称--------------{$CATEGORYS[$CAT[parentid]][catname]}
父栏目链接--------------{$CATEGORYS[$CAT[parentid]][url]}
上上级栏目名称----------{$CATEGORYS[$CATEGORYS[$CAT[parentid]][parentid]][catname]}
上上级栏目链接----------{$CATEGORYS[$CATEGORYS[$CAT[parentid]][parentid]][url]}
{$CATEGORYS[$catid][url]} 指定栏目URL代码
{$CATEGORYS[$catid][catname]} 指定栏目名称代码
{$CATEGORYS[41][url]} 指定栏目ID为41的URL
{$CATEGORYS[41][catname]}指定栏目ID为41的栏目名
{$CATEGORYS[$catid][items]} 调用一个栏目的数量条数
<?php $CATEGORYS = getcache('category_content_1','commons');?>(此方法直接调用,上面是调用缓存数据)
一级父栏目列表
{pc:content action="category" catid="0" num="34" siteid="$siteid" order="listorder ASC"}
{loop $data $r}
<li><a href="{$r[url]}">{$r[catname]}</a></li>
{/loop}
{/pc}
<!--同级栏目列表-->
{pc:content action="category" catid="$parentid" num="99" siteid="$siteid" order="listorder ASC"}
{loop $data $r}
<li><a href="{$r[url]}">{$r[catname]}</a></li>
{/loop}
{/pc}
<!--文章列表 可选属性start="0"从第几条开始循环-->
{pc:content action="lists" catid="" num="" order="listorder ASC,inputtime DESC,id DESC" page="$page"}
{loop $data $r}
{$r[url]}文章链接 {$r[title]}文章标题 {str_cut($r[title],99,'...')}文章标题缩
{date("Y-m-d",$r[inputtime])}发布日期 {$pages}列表分页 {thumb($r[thumb],217,63)}缩略图
{str_cut($r[description],180)}文章摘要 {str_cut(strip_tags($v[content]),120,'...')}去除HTML代码后的正文截取
{/loop}
{$pages}
{/pc}
<div class="pagelist">{$pages}</div>
显示结果条数{count($data)}或{sizeof($data)}
时间日期转换{format::date($r[inputtime],1)}
<!--文章正文-->
{$title}标题
{$username}作者
{date('Y-m-d',strtotime($inputtime))}发布日期
{$copyfrom}信息来源
{$content}正文
访问次数
<span id="hits"></span><script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script>
上一篇{$previous_page[url]} {$previous_page[title]}
下一篇{$next_page[url]} {$next_page[title]}
文章关键词: {loop $keywords $keyword}<a href="{APP_PATH}index.php?m=content&c=tag&catid={$catid}&a=lists&tag={urlencode($keyword)}" target="_blank"> {$keyword}</a> {/loop}
<!--热点信息-->
{pc:content action="hits" catid="15,16,17,18,19,20,21" order="weekviews DESC" num="4"}
{loop $data $key $val}
{/loop}
{/pc}
<!--实现多栏目的热点信息调用-->
{pc:get sql="SELECT * FROM xy_news,xy_hits WHERE id=SUBSTRING_INDEX(hitsid,'-',-1) AND xy_news.catid IN (1,2,3) AND SUBSTRING_INDEX(SUBSTRING_INDEX(hitsid,'-',-2),'-',1)=1 ORDER BY weekviews DESC" num="5" return="data"}
{loop $data $v}
{/loop}
{/pc}
<!--GET万能标签-->
{pc:get sql="SELECT * from xy_news where status=99 and catid in(24,26,27) order by listorder DESC,inputtime DESC,id DESC" num="10" return="data" page="$page"}
{loop $data $v}
{$v[title]}
{date("Y-m-d",$v[inputtime])}
{/loop}
{/pc}
SELECT * FROM xy_news,xy_news_data WHERE xy_news.id=xy_news_data.id AND catid=86 ORDER BY listorder ASC,inputtime DESC
zoom放大缩小
<script language="javascript">function doZoom(size){document.getElementById('zoom').style.fontSize=size+'px';}</script>
<!--调用文字友情链接-->
{pc:link action="type_list" siteid="$siteid" order="listorder DESC" num="10" return="dat"}
{loop $dat $v}
<a href="{$v[url]}" target="_blank">{$v[name]}</a> |
{/loop}
{/pc}
<!--调用图片友情链接-->
{pc:link action="type_list" siteid="$siteid" linktype="1" order="listorder DESC" num="8" return="pic_link"}
{loop $pic_link $v}
<li><a href="{$v[url]}" title="{$v[name]}" target="_blank"><img src="{$v[logo]}" width="88" height="31"
/></a></li>
{/loop}
{/pc}
<!--调用推荐位-->
{pc:content action="position" posid="9" order="id DESC" num="10" cache="3600"}
{loop $data $k $r}
<a href="{$r[url]}">{$r[title]}</a>
{/loop}
{/pc}
<!--调用点击数-->
<span id="hits"></span>
<script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script>
<!--视频播放器调用,支持flv、mp4、等网页格式-->
<embed src="http://s44.cc/player/ckplayer.swf" flashvars="f=视频地址&p='1'" quality="high" width="650" height="480" align="middle" allowscriptaccess="always" allowfullscreen="true" type="application/x-shockwave-flash">
<!--列表页调用浏览次数-->
{get_views('c-'.$CATEGORYS[$r[catid]][modelid].'-'.$r[id])}
<!--组图列表-->
{loop $photos $r}
<li><a href="{$r[url]}"><img src="{thumb($r[url], 75, 45, 0)}" alt="{$r[alt]}" /></a></li>
{/loop}
注释:其中$photos为自定义组图字段,{$r[url]}为图片地址,{thumb($r[url], 75, 45, 0)}为图片缩略图,{$r[alt]}为图片描述
<!--V9同时调用多个栏目最新文章标签-->
{pc:get sql="SELECT `n`.`inputtime`,`n`.`url`,`n`.`title`,`c`.`catname`,`c`.`url` as `c_url` FROM `v9_news` as `n` left join `v9_category` as `c` on `n`.`catid` = `c`.`catid` where `c`.`catid` in (6,7,8,9,10) order by `n`.`id` desc" num="10" cache="3600" page="" dbsource="" return="data"}
{loop $data $key $val}
<li><span class="date">{date('Y-m-d H:i:s',$val[inputtime])}</span>[<a href="{$val[c_url]}" target="_blank">{$val[catname]}</a>] <a href="{$val[url]}" title="{$val[title]}" target="_blank">{$val[title]}</a></li>
{/loop}
{/pc}
<!--首页头条-->
{pc:content action="position" posid="2" order="listorder DESC" num="1"}
{loop $data $r}
<div class="headlinetop"> <a href="{$r[url]}" target="_blank">
<h3>{str_cut($r[title],20,'')}</h3>
<p>{str_cut($r[description],102)}</p>
</a> </div>
{/loop}
{/pc}
<!--外部数据源调用-->
{pc:get sql="SELECT * FROM pre_forum_thread" cache="3600" dbsource="discuz" return="data" num="10"}
<!--字符集 (gbk或者utf-8)-->
{CHARSET}
<!--调用全站内容,按照流量次数排序-->
{pc:get sql="SELECT a.id,a.url,a.title,a.status,b.hitsid,b.views FROM v9_news a, v9_hits b WHERE a.status=99 and a.id=substring(b.hitsid,5) ORDER BY b.views DESC" num="6"}
{loop $data $r}
<div class="list t2{if $i%3==0} mr0{/if}"><a href="{$r[url]}">{$r[title]}</a><span>人气:{$r[views]}</span></div>
{php $i++}
{/loop}
{/pc}
<!--列表页调用关键词(',',$r[keywords])逗号为分隔符)-->
{php $keywords = explode(',',$r[keywords]);}
{loop $keywords $keyword}
<a href="{APP_PATH}index.php?m=content&c=tag&a=lists&tag={urlencode($keyword)}">{$keyword}</a>
{/loop}
<!--调用文章导航-->
{if $titles}
<fieldset>
<legend>本文导航</legend>
<ul>
{loop $titles $r}
<li>{$n}、<a href="{$r[url]}">{$r[title]}</a></li>
{/loop}
</ul>
</fieldset>
{/if}
<!--嵌套循环-->
{loop subcat(38,0,0,$siteid) $r}
{php $cid=$r[arrchildid]}
{pc:get sql="SELECT * from xy_news where status=99 and catid=$cid and typeid in(54) order by listorder ASC,inputtime DESC" num="1" return="data"}
{loop $data $jj}
{/loop}
{/pc}
{/loop}
<!--相关文章-->
{pc:content action="relation" relation="$relation" catid="$catid" num="5" keywords="$rs[keywords]"}
{loop $data $r}
<li><a href="{$r[url]}" target="_blank">{$r[title]}</a><span>({date('Y-m-d',$r[inputtime])})</span></li>
{/loop}
{/pc}
<!--判断是否有数据-->
{if empty($data)}
<span class="nothing">暂无相关信息!</span>
{/if}
<!--日期转换-->
2014-11-20 11:11:11 {date('Y-m-d H:i:s',$v[inputtime])}
2014-11-20 {date('Y-m-d',$v[inputtime])}
<!--循环显示子栏目信息-->
{pc:get sql="SELECT arrchildid from xy_category where catid=$catid" num="1" return="cata"}
{loop $cata $lm}
{pc:get sql="SELECT * from xy_news where status=99 and catid in($lm[arrchildid]) order by inputtime DESC,id DESC" num="10" return="data" page="$page"}
{php $u=0}
<ul>
{if empty($data)}
<li class="zixun_lb_news sy12">暂无相关信息!</div>
{/if}
{loop $data $v}
{php $u++}
<li class="zixun_lb_news sy12">·<a href="{$r[url]}" target="_blank">{$v[title]}</a></li>
<li class="zixun_lb_news_time sy15">{date('Y-m-d',$v[inputtime])}</li>
{if $u%5==0 && $u<10} </ul><ul> {/if}
{/loop}
</ul>
<div id="page-con-right-list-fy">{$pages}</div>
</div>
{/pc}
{/loop}
{/pc}
<!--专题标签-->
首页 $id 专题ID $title 专题名称
列表 $id 专题ID $title 专题名称 $typeid 分类ID $info[name] 分类名称
专题当前位置
<div id="zixun_nr_dh_02" class="sy13">当前位置:<a href="{siteurl($siteid)}">首页 > </a><a href="{$url}">{$title}</a> > <a href="{$info[url]}">{$info[name]}</a></div>
<!--判断字符串是否含有子串-->
{if $hd[thumb] && stristr($hd[thumb],"dangyang.gov.cn/")}
17.从单信息获取图片和内容摘要(正则匹配)
{pc:get sql="SELECT * from xy_page where catid=306" num="1"}
{loop $data $v}
{php $curl=$CATEGORYS[306][url]}
{php $img=IMG_PATH.'nopic.gif'}
{php preg_match('/<img.+src=\"?(.+\.(jpg|gif|bmp|bnp|png))\"?.+>/i',$v[content], $out)}
{php if($out[1]) $img=$out[1]}
<span>
{if $out[0]}
{php echo str_cut(preg_replace('/<[^>]+>/','',$out[0]),560,'...')}
{else}
{php echo str_cut(preg_replace('/<[^>]+>/','',$v[content]),560,'...')}
{/if}
<a href="{$curl}">详情</a>
</span>
<img src="{$img}" width="387" height="236" />
{/loop}
{/pc}
<!--读取用户真实姓名-->
phpcms\libs\functions\global.func.php
/**
* Function get_realname
* 通过username值,查询真实姓名
* @param $username 用户名
*/
function get_realname($username) {
if(empty($username)){return false;}
$admin_db = pc_base::load_model('admin_model');
$realname = $admin_db->get_one(array('username'=>$username),'realname');
//如果没有真实姓名返回用户名
if($realname[realname]) {
return $realname[realname];
} else {
return $username;
}
}
<!--搜索、Tag页、模块页面不支持$CATEGORYS的解决方法-->
加上<?php $CATEGORYS = getcache('category_content_{$siteid}','commons');?>
<!--对于图片相对路径进行的判断-->
{if $r[thumb] && stristr($r[thumb],"http://")}
<img src="{thumb($r[thumb],316,260)}" alt="{$r[title]}" width="316" height="262" />
{else}
<img src="{thumb('http://www.dangyang.gov.cn'.$r[thumb],316,260)}" alt="{$r[title]}" width="316" height="262" />
{/if}
<!--搜索框代码-->
<form class="navbar-form isearch mt20 " role="isearch" action="{APP_PATH}index.php?m=search&siteid=1" method="get" target="_blank">
<div class="form-group col-xs-8 col-md-6 col-xs-offset-1 col-md-offset-2">
<input type="hidden" name="m" value="search"/>
<input type="hidden" name="c" value="index"/>
<input type="hidden" name="a" value="init"/>
<input type="hidden" name="typeid" value="55" id="typeid"/>
<input type="hidden" name="siteid" value="1" id="siteid"/>
<input type="text" class="form-control" placeholder="请输入关键词" name="q" id="q" />
</div>
<button type="submit" class="btn col-xs-2 col-md-2 submit">搜索</button>
<div class="cf"></div>
</form>
<!--一级、二级栏目调用-->
<div>
<ul>
<li><h3><a href="{siteurl($siteid)}">首页</a></h3></li>
{pc:get sql="SELECT * FROM v9_category WHERE ismenu=1 and siteid=1 and parentid=0 ORDER BY listorder ASC"}
{loop $data $r}
<li>
<h3><a href="{$r[url]}">{$r[catname]}</a></h3>
{if $r[child]==1}
<ul>
{loop subcat($r[catid]) $r2}
<li><a href="{$r2[url]}">{$r2[catname]}</a></li>
{/loop}
</ul>
{/if}
</li>
{/loop}
{/pc}
</ul>
</div>
数据调用
link 连接地址 text
is_blank 新窗口打开? box
产品中心
以下未整理
6、指定变量循环增长(幻灯片调用)
{pc:content action="position" posid="1" order="listorder DESC" thumb="1" num="5"}
<div class="content" id="main-slide">
<div class="changeDiv">
{loop $data $r}
<a href="{$r[url]}" title="{str_cut($r[title],30)}"><img src="{thumb($r[thumb],310,260)}" alt="{$r[title]}" width="310" height="260" /></a>
{/loop}
</div>
</div>
{/pc}
{pc:content action="lists" catid="66" order="listorder DESC" thumb="1" num="5" }
{php $num = 0}
{loop $data $r}
linkarr[{$num}] = "{$r[url]}";
picarr[{$num}] = "{$r[thumb]}";
textarr[{$num}] = "{str_cut($r[title],36,'')}";
{php $num++}
{/loop}
{/pc}