phpcms 2008网站建设常用代码收集
碎片:<!--{block("list_down", 1)}-->
文章摘要: {str_cut($r[description],xx,'...')}
文章网址: {$r[url]}
文章标题: {$r[title]} {str_cut($r[title],44,'')}
文章时间:{date('Y-m-d', $r[updatetime])}
模板路径:{SKIN_PATH}
调用头部页面 :{template 'phpcms','header'}
商务通链接网址:/swt/go.php?from=xxx
设定域名:<base href="{SITE_URL}" />
栏目名称:{$catname}
栏目+列表当前位置:{catpos($catid)}
文章页面当前位置:{catpos($r['catid'])}
tag_标签内容列表
select * from `phpcms_content` a,`phpcms_content_tag` k where a.contentid=k.contentid and a.status=99 and k.tag='$tag' order by a.contentid desc
===============================================
category.html常用标签:
==============================================
调用栏目网址:{$CATEGORY[$catid][url]} {$CATEGORY[112][url]}
调用栏目名称:{$CATEGORY[$catid][catname]} {$CATEGORY[112][catname]}
调用热点文章(按每月点击次数排序):
{get sql=" SELECT a.* FROM `phpcms_content` a, `phpcms_content_count` p WHERE a.contentid=p.contentid AND a.status=99 ORDER BY p.hits_month DESC limit 2,5" }
调用分类ID为36的一条新闻文章1条:
{get sql="select * from `phpcms_content` where status=99 and catid=36 ORDER BY updatetime DESC limit 0,1"}
调用某个栏目下的普通文章5条,并分页显示:
{get sql="select * from `phpcms_content` where status=99 and catid=80 ORDER BY updatetime DESC" rows="5" page="$pages"}
调用缩略图文章1条:
{get sql="select title,url,thumb,description from `phpcms_content` where status=99 and thumb!='' and catid=xxxx ORDER BY updatetime DESC limit 0,1" } {$r[thumb]}
--------------------------------------------------------------------------------------------------------------------------
index.html常用标签:
----------------------------------------------------------------------------------------------------------------------------
友情链接:
{get sql="select * from `phpcms_link`where passed=1 order by listorder"}
链接网址: {$r[url]}
链接名:{$r[name]}
幻灯片:
{get sql="SELECT a.title,a.url,a.thumb FROM `phpcms_content` a, `phpcms_content_position` p WHERE a.contentid=p.contentid AND p.posid=2 AND a.status=99 AND `thumb`!='' ORDER BY a.contentid DESC"}
linkarr[{$n}] = "{$r[url]}";<!--注意-$n要加上{}-->
picarr[{$n}] = "{$r[thumb]}";
网站热门关键词:
{get sql="select tag,hits from phpcms_keyword order by listorder desc,hits desc" rows="10"}
<a href="tag.php?tag={urlencode($r[tag])}">{$r[tag]}</a>
{$r[hits]}
{/get}
获取父栏目下的子级栏目:
{get sql="select * from `phpcms_category` where parentid =$catid order by listorder"}
{get sql="select * from `phpcms_content` where status=99 and catid = $r[catid] ORDER BY updatetime DESC" rows="4" return="ar"}
栏目链接网址 {$ar[url]}
栏目名称 {$ar[catname]}
{/get}
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
list.html 常用标签:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
当前栏目文章每页分10条的分页代码
{get sql="select * from `phpcms_content` where catid = $catid and status=99 order by updatetime desc" rows="10" page="$pages" }
分页:{$pages}
推荐阅读;首页推荐posid=1 首页焦点posid=2 首页头条posid=3 列表页推荐posid=4 内容页推荐posid=5
{get sql="SELECT a.* FROM `phpcms_content` a, `phpcms_content_position` p WHERE a.contentid=p.contentid AND p.posid=1 AND a.status=99 AND a.catid=39 order by updatetime desc" rows="1"}
{/get}
4、自定义返回变量,示例(调用栏目ID为1通过审核的10条信息,标题长度不超过25个汉字,显示更新日期,返回变量为 $v):
{get sql="select * from phpcms_content where catid=1 and status=99 order by updatetime desc" rows="10" return="v"}标题:{str_cut($v[title], 50)} URL:{$v[url]} 更新日期:{date('Y-m-d', $v[updatetime])} {/get}
5、调用同一帐号下的其他数据库,示例(调用数据库为bbs,分类ID为1的10个最新主题,主题长度不超过25个汉字,显示更新日期):{get dbname="bbs" sql="select * from cdb_threads where fid=1 order by dateline desc" rows="10"}主题:{str_cut($r[subject], 50)} URL:http://bbs.phpcms.cn/viewthread.php?tid={$r[tid]} 更新日期:{date('Y-m-d', $r[dateline])} {/get}
6、调用外部数据,示例(调用数据源为bbs,分类ID为1的10个最新主题,主题长度不超过25个汉字,显示更新日期):{get dbsource="bbs" sql="select * from cdb_threads where fid=1 order by dateline desc" rows="10"}主题:{str_cut($r[subject], 50)} URL:http://bbs.phpcms.cn/viewthread.php?tid={$r[tid]} 更新日期:{date('Y-m-d', $r[dateline])} {/get}
7、调用ecshop数据,示例(调用数据源为ecshop,调用产品库中最新的5个产品):{get dbsource="ecshop" sql="SELECT `goods_id`,`goods_name`,`goods_thumb` FROM `ecs_goods` ORDER BY `goods_id` DESC" rows="5" }产品ID:{$r[goods_id]} 名称:{$r[goods_name]} 产品图片:{$r[goods_thumb]} {/get}
获取当前大栏目 下的各个小栏目的文章;
<?php $arrchildid1=$CATEGORY[$catid][arrchildid]; ?>
{get sql="select * from `phpcms_content` where status=99 and catid in($arrchildid1) ORDER BY inputtime asc" rows="1"}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
show.html页面标签:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
文章标题:{if $titleintact}{$titleintact}{else}{$title}{/if}
文章来源:{$copyfrom}
文章作者:{$author}
更新时间:{date('Y-m-d', $r[updatetime])}
文章内容:{$content}
上一篇:
{get sql="SELECT * FROM `phpcms_content` WHERE `contentid` < '$contentid' and status = 99 ORDER BY inputtime DESC" rows="1"}
<a class='LinkPrevArticle' href='{$r[url]}' title='{$r[title]}'>{$r[title]}</a>
补充:web前端 , HTML/CSS ,