PHPCMS快速建站系列之常用标签
<span class="Nmore"><a href="/index.php?m=content&c=index&a=lists&catid=79">更多»</a></span>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
右边加new小图标:{if time()-$r[inputtime]<7*24*3600}<img src='/statics/images/new.gif' />{/if}
统计:{tjcode()}
碎片:{pc:block pos="scroll"}{/pc}
头部:
<meta http-equiv="Content-Type" content="text/html; charset={CHARSET}" />
<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']}">
常用系统常量: {CSS_PATH} {JS_PATH} {IMG_PATH} {APP_PATH}//程序目录
模板包含:{template "content","header"} {template "content","sidebar"} {template "content","footer"}
------常用调用数据-------
{pc:content action="lists" catid="6" num="8" order="inputtime DESC" }
{loop $data $r}
<li><span class="date">({date('Y/m/d H:m:s',$r[inputtime])})</span><a href="{$r[url]}" target="_blank" title="{$r[title]}">{str_cut($r[title],'28')}</a></li>
{/loop}
{/pc}
{str_cut(strip_tags($r[description]), 165)}
常用标签:{$r[thumb]}
推荐位调用:
{pc:content action="position" posid="1" order="listorder DESC" num="5"}
{loop $data $r}
<li><a href="{$r[url]}" target="_blank"><img src="{$r[thumb]}" text="{$r[title]}" alt="{$r[title]}" width="727" height='243' /></a></li>
{/loop}
{/pc}
一级栏目调用:
{pc:content action="category" catid="0" num="8" siteid="$siteid" order="listorder ASC"}
{loop $data $r}
<li><a href="{$r[url]}" title="{$r[catname]}">{$r[catname]}</a></li>
{/loop}
{/pc}
当前栏目风格:
{if $catid==$r[catid]} class="current"{/if}
在文章前显示文章分类名:
{pc:content action="lists" catid="2" order="listorder DESC" num="14" }
<?php $TYPE = getcache('type_content','commons');?>
{loop $data $n $r}
<li>{if $TYPE[$r[typeid]][name]}<span style="color:#CC6600">[ {$TYPE[$r[typeid]][name]}] </span>{/if}<a href="{$r['url']}" title="{$r['title']}" target="_blank">{str_cut($r[title],33,'')}</a></li>
{/loop}
{/pc}
指定变量循环增长:
{pc:content...
{php $num = 0}
{loop $data $r}
...
{php $num++}
{/loop}
{/pc}
文章从指定位置调用:num="3" start="5"} (可配合pc:get标签使用)
文章列表页调用关键字,或者首页调用关键字:
{pc:content action="lists" catid="$catid" num="10" order="id DESC" page="$page"}
{loop $data $r}
<a href="{$r[url]}">{$r[title]}</a>
php $keywords = explode(',',$r[keywords]);}
<b>文章标签:</b>
{loop $keywords $keyword}
<a href="{APP_PATH}index.php?m=content&c=tag&catid={$catid}&tag={urlencode($keyword)}" class="blue"> {$keyword}</a>
{/loop}
{/loop}
{/pc}
当列表几行的时候出现一次某些符号:{if $n%2==1}|{/if}
-------------------列表页调用-------------------------
当前位置显示:
<div
class="postion">当前位置:<a href="{siteurl($siteid)}">首页</a><span> > </span>{catpos($catid)} 列表</div>
当前栏目名称:{$catname}
获取父栏目id/获取父栏目名称:{$CATEGORY[$catid][parentid]} / {$CATEGORYS[$CAT[parentid]][catname]}
指定ID栏目名称:{$CATEGORYS[栏目ID号]['catname']} / {$CATEGORYS[$catid]['catname']}
其他常用调用:{$r[description]} {$r[image]}
列表内容显示(带分页):
<div class="news_list2">
<ul>
{pc:content action="lists" catid="$catid" num="20" order="id DESC" page="$page"}
{loop $data $r}
<li><span class="date">{date('Y-m-d H:i:s',$r[inputtime])}</span><a href="{$r[url]}" target="_blank" title="{$r[title]}">{$r[title]}</a></li>
{/loop}
</ul>
<div id="pages" class="text-c">{$pages}</div>
{/pc}
</div><!-- news_list end-->
显示该栏目下的子栏目:
{if $top_parentid}
{pc:content action="category" catid="$top_parentid" num="15" siteid="$siteid" order="listorder ASC"}
{loop $data $r}
<li><a href="{$r[url]}">{$r[catname]}</a></li>
{/loop}
{/pc}
{/if}
如果栏目下边没有子类,那么显示一级分类
<?php
if($top_parentid==""){
?>
{pc:content action="category" catid="0" num="100" siteid="$siteid" order="listorder ASC"}
{loop $data $r}
<li><a href="{$r[url]}">{$r[catname]}</a></li>
{/loop}
{/pc}
<?php }else{ ?>
{pc:content action="category" catid="$top_parentid" num="100" siteid="$siteid" order="listorder ASC"}
{loop $data $r}
<li><a href="{$r[url]}">{$r[catname]}</a></li>
{/loop}
{/pc}
<?php } ?>
频道页:
{php $j=1;}
{loop subcat($catid) $v}
{php if($v['type']!=0) continue;}
<div class="cat_name"><span class="Nmore"><a href="{$v[url]}">更多»</a></span>{$v[catname]}</div>
<div class="news_list2">
<ul>
{pc:content action="lists" catid="$v[catid]" num="5" order="id DESC"}
{loop $data $r}
<li><span class="date">{date('Y-m-d',$r[inputtime])}</span><a href="{$r[url]}" target="_blank" title="{$r[title]}">{$r[title]}</a></li>
{/loop}
{/pc}
</ul>
</div>
<!-- news_list end-->
<div class="cl"></div>
{$j++}
{/loop}
如果想在调用五个栏目内容的话,在{$j++}下面加入:
{php if ($j>=5) break;}
如果要排除某个栏目的循环,可以在{php if($v['type']!=0) continue;}下面加入:
{php if($v['catid']==7) continue;}
或:{php if($r['catid']==9 || $r['catid']==10 || $r['catid']==11)continue;}
---------------------文章内容页-------------------
显示内容:
{$title} {$inputtime} {$content} {$copyfrom} {$thumb} 当前所属栏目:{$CAT[catname]} 当前所属栏目URL:{$CAT[url]}
获取多文件类型的上传的第一个文件地址:{php eval("\$arr=" . $r[upload] . ";");echo $arr[0]['fileurl'];}
父栏目名称与链接:{$CATEGORYS[$CAT[parentid]][catname]} 与 {$CATEGORYS[$CAT[parentid]][url]}
获取上上级栏目名称与链接:{$CATEGORYS[$CATEGORYS[$CAT[p
arentid]][parentid]][catname]} 与 {$CATEGORYS[$CATEGORYS[$CAT[parentid]][parentid]][url]}
组图列表:
{loop $photos $r}
<li><a href="{$r[url]}"><img src="{thumb($r[url], 75, 45, 0)}" alt="{$r[alt]}" /></a></li>
{/loop}
浏览次数:
<span id="hits"></span>次
<script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script>
显示上一页和下一页:
<p class="f14">
<strong>上一篇:</strong><a href="{$previous_page[url]}">{$previous_page[title]}</a><br />
<strong>下一篇:</strong><a href="{$next_page[url]}">{$next_page[title]}</a>
</p>
文章内容分页:<div id="pages" class="text-c">{$pages}</div>
加载评论:
{if $allow_comment && module_exists('comment')}
<iframe src="{APP_PATH}index.php?m=comment&c=index&a=init&commentid={id_encode("content_$catid",$id,$siteid)}&iframe=1" width="100%" height="100%" id="comment_iframe" frameborder="0" scrolling="no"></iframe>
{/if}
-----------PC:get语句调用数据---------------
用pc:get时的记录条数时分页显示:
解决办法一:
{pc:get sql="SELECT title,url FROM v9_news where catid=9 and status=99 order by updatetime desc" start="0" num="4" return="v"}
解决办法二:
{pc:get sql="SELECT title,url FROM v9_news where catid=9 and status=99 order by updatetime desc limit 0,4--" return="v"}
在首页某模型所有栏目最新文章调用带栏目名称
{pc:get sql="select * from v9_convert_news where status=99 order by id desc" num="11"}
{loop $data $v}
<li style="text-align:center;"><a href="{$CATEGORYS[$v[catid]][url]}" style="font-size:12px; color:#F30">{str_cut($CATEGORYS[$v[catid]][catname],45,'...')}</a></li>
<li style="width:280px;">
| <a href="{$v['url']}" title="{$r[title]}" target="_blank">{str_cut($v[title],90)}</a></li>
{/loop}
{/pc}
---------------------友情链接-----------------------------------------------------------------------
{pc:link action="type_list" typeid="0" siteid="1" linktype="1" order="listorder DESC" num="8"}
{loop $data $v}
<a href="{$v['url']}" title="{$v['name']}" target="_blank">{$v['name']}</a>
{/loop}
{/pc}
一般常用标题: {$v['url']} {$v['url']} {$v['logo']}
注:linktype="1"时为图片友情。为0时为文本链接
--------------------站点列表----------------------------------------------------------------------
{pc:get sql="select name,domain from v9_site where siteid<>1 order by siteid asc"}
{loop $data $r}
<a href="{$r[url]}" target="_blank" title="{$r[name]}">{$r[name]}</a>
{/loop}
{/pc}
--------------调用单页内容-------------------------------
{pc:get sql="SELECT content FROM v9_page where catid='6'" return="data"}
{loop $data $r}
{str_cut(strip_tags($r[content]), 160)}
{/loop}
{/pc}
---------------调用排行-----------------
{pc:content action="hits" catid="13" order="weekviews DESC" num="4"}
{loop $data $r}
<li> <a href="{$r['url']}">
{$r['title']}</a></li>
{/loop}
{/pc}
{pc:get sql="select * from ns_gck where catid in(415,420,421,422,423,424,425)" num="10" return="data"}
{loop $data $r}
<li><a href="{$r[url]}" title="{$r[title]}">{str_cut($r[title],"28")}</a></li>
{/loop}
{/pc}
——-------------在LIST中调用文章的浏览次数---------------------------
把以下代码加在{pc:content action="hits"......中合适的地方即可:
{php $h_md=pc_base::load_model('hits_model');$get_db=$h_md->get_one(array('hitsid'=>"c-".$modelid."-".$r[id]));$views=$get_db[views];}
点击量:{$views}
---------------------------全站最新文章-------------------------------
{pc:content action="newcontent" order="8" num="7"}
{loop $data $r}
<li>[{$CATEGORYS[$r[catid]][catname]}]<a href="{$r['url']}">{str_cut($r['title'],28)}</a></li>
{/loop}
{/pc}
列表页调关键词:
TAG:{loop $keywords $keyword}
<a href="{APP_PATH}index.php?m=content&c=tag&a=lists&tag={urlencode($keyword)}">{$keyword}</a>
{/loop}
PHPCMS快速建站系列之常用标签的更多相关文章
- PHPCMS快速建站系列之 pc标签where中如何使用变量
{pc:content action="lists" catid="$catid" where="typeid='$t'" order=&q ...
- PHPCMS快速建站系列之标签循环嵌套
标签循环嵌套方法,可以实现对PC标签循环调用,代码如下: 在此文件里/phpcms/lib/classes/template_cache.class.php 里的 template_parse 方法里 ...
- PHPCMS快速建站系列之标签调用出错
{pc:content action="position" posid="24" order="listorder ASC" thumb=& ...
- PHPCMS快速建站系列之phpcms v9 模板标签说明整理
[摘要]本文介绍phpcms v9中模板标签使用说明. {template "content","header"} 调用根目录下phpcms\template\ ...
- PHPCMS快速建站系列之pc:get标签的应用
GET标签使用方式如下: {pc:get sql="SELECT * FROM phpcms_member" cache="3600" page="$ ...
- PHPCMS快速建站系列之需要掌握的函数
路径:phpcms\libs\classes\model.class.php /** * 执行sql查询 * @param $where 查询条件[例`name`='$name'] * ...
- PHPCMS快速建站系列之自定义分页函数
内容分页的实现方法:{pc:content action="lists" catid="$catid" order="id DESC" nu ...
- PHPCMS快速建站系列之邮箱验证
1. 登录163邮箱,->设置,开启POP3服务->把SMTP服务器地址复制到PHPCMS后台. 2.开启客户端授权密码 3.填写相关信息,.可以在测试邮箱填入邮箱地址测试
- PHPCMS快速建站系列之后台内容自定义修改
一.后台登录页面 背景图:\statics\images\admin_img 中的 login_bg.jpg 底部版权信息:\phpcms\languages\en 中的 system.lang.ph ...
随机推荐
- Python - 基本数据类型及其常用的方法之元组
元组 特点:一级元素无法被修改,且不能被增加或者删除. 基本操作: tu = (11, 22, ["aiden", 33, ("qwe", 11)], 77) ...
- python-基础-面象对象
1 类和对象 定义类 定义一个类,格式如下: class 类名: 方法列表 demo:定义一个Car类 # 定义类 class Car: # 方法 def getCarInfo(self): prin ...
- js 获取复选框 和 并改变状态
function checkAll() { var checkbox = document.getElementById('vegeids');// var boxes = document.getE ...
- linux下C++遍历文件夹下的全部文件;Windows/Linux下C++批量修改文件名,批量删除文件
Linux下 C++遍历目录下所有文件 rename(image_path.c_str(), image_path_new.c_str()); remove(image_path_move.c_str ...
- 【python之路33】开发模式单例模式及简单的服务器请求框架原理
1.单例模式指的是创建单个实例,例如:数据库连接池中包含10个数据库连接,用户访问数据时随机从连接池中拿出一个进行连接,其他用户再次访问时不再创建对象进行连接 #!usr/bin/env python ...
- tyvj 1423 GF和猫咪的玩具
传送门 解题思路 题目比较水,floyd求出最短路取个最小值即可.结果joyoi时限写错了..好像只有0ms才能过??突然发现加了快读就T不加就A,数据在10000以下的还是scanf快啊. 代码 # ...
- 作业-[luogu4396][AHOI2013]-莫队
<题面> 卡常终究比不上算法的优化…… 这是莫队的有点小坑的题, 首先不一定能想到,想到不一定打对,打对不一定打好. 首先你会发现,这个题的时限是很长的- $n$和$m$也是很大的. 于是 ...
- LintCode_44 最小子数组
题目 给定一个整数数组,找到一个具有最小和的子数组.返回其最小和. 注意事项 子数组最少包含一个数字 样例 给出数组[1, -1, -2, 1],返回 -3 思路 动态规划解决 C++代码 int m ...
- jeecms系统使用介绍——jeecms中的内容、栏目、模型之间的关系
转载:https://blog.csdn.net/dongdong9223/article/details/76578120 jeecms是一款很不错的cms产品,之前在文章<基于Java的门户 ...
- fixed和absolute的区别
今天在实际项目中,写首页一屏的时候,发现页脚定位(position:absolute:)没有达到我想要的效果(不管屏幕大小,页脚始终相对浏览器底部定位).于是我觉得有点奇怪,然而我旁边的小哥说:很明显 ...