phpcmsv9模板常用标签
1、父栏目的子栏目列表调用
<div class="sidebar_tit">{$catname}</div> <div class="Btop sidenav"> <ul> {pc:content action="category" catid="$parentid" num="15" siteid="$siteid" order="listorder ASC"} {loop $data $r} <li>< a href=" ">{$r[catname]}</ a></li> {/loop} {/pc} </ul> </div> </div>
2、当前栏目热门阅读
<div class="sidebar_tit">热门阅读</div> <div class="Btop sidelis"> <ul> {pc:content action="hits" catid="$catid" num="10" order="views DESC" cache="3600"} {loop $data $r} <li>< a href=" " target="_blank">{$r[title]}</ a></li> {/loop} {/pc} </ul> </div> </div>
3、内容页自定义字段多图调用
{loop $xijietu $v} //xijietu 自定义字段 <a href ="{$v[url]}" target="_blank"><img src="{thumb($v[url],100,100)}" atl=""/></a> {/loop}
5、栏目图片调用:
<img alt="{$r[catname]}" src="{$CATEGORYS[$catid][image]}" class="MW1280 MH415">
6、首页调用单页面内容
{pc:get sql="SELECT * FROM v9_page where catid=21"} {loop $data $val} {str_cut(strip_tags($val[content]),400,'…')} {/loop} {/pc}
7、导航输出顶级栏目和二级栏目
{pc:content action="category" catid="0" num="25" siteid="$siteid" order="listorder ASC"} {loop $data $r} <li class="nav_li"><a class="navigation_a" href="{$r[url]}" target="_self" title="{$r[catname]}">{$r[catname]}</a> {if $r[child}//是否有子栏目判断 <ul style="display: none;"> {pc:content action="category" catid="$r[catid]" num="25" siteid="$siteid" order="listorder ASC" return="data2"} {loop $data2 $v} <li><a class="navigation2_a" title="{$v[catname]}" href="{$v[url]}" target="_self">{$v[catname]}</a></li> {/loop} {/pc} </ul> {/if} </li> {/loop} {/pc}
8、当前栏目是否有子栏目判断
{if $parentid==0} <!--是否顶级栏目判断--> <div style="background-color:#ea0011; font-size:18px; text-align:center; line-height:45px; height:45px; color:#ffffff;">{$catname}</div> {pc:content action="category" catid="$catid" num="25" siteid="$siteid" order="listorder ASC"} {loop $data $r} <a class="left_a" href="{$r[url]}" title="$r[catname]}"> {$r[catname]}</a> {/loop} {/pc} {else} <!--非顶级栏目--> <div style="background-color:#ea0011; font-size:18px; text-align:center; line-height:45px; height:45px; color:#ffffff;">{$CATEGORYS[$CAT[parentid]][catname]}</div> {pc:content action="category" catid="$parentid" num="25" siteid="$siteid" order="listorder ASC"} {loop $data $r} <a class="left_a" href="{$r[url]}" title="$r[catname]}"> {$r[catname]}</a> {/loop} {/pc} {/if}
9、父栏目id:{$CATEGORYS[$catid][parentid]}
父栏目名称:{$CATEGORYS[$CAT[parentid]][catname]}
内容页栏目名:{$CATEGORYS[$catid][catname]}
内容页获取所在栏目的上一级栏目的id:$CAT[parentid]
内容页获取所在栏目链接:{$CATEGORYS[$catid][url]}
内容页日期格式化{date('Y年-m月-d日',strtotime($inputtime))}
通用栏目名称调用:{$CATEGORYS[栏目id][catname]}
通用栏目链接调用:{$CATEGORYS[$栏目id][url]}
通用栏目图片调用:{$CATEGORYS[$栏目id][image]}
通用栏目描述调用:{$CATEGORYS[$栏目id][description]}
10、表单数据调用
{pc:get sql="select name,tel,email,content from v9_form_orders order by dataid desc" num="4"} {loop $data $r} <td> <tr>{$r[name]}</tr> <tr>{$r[tel]}</tr> <tr>{$r[email]}</tr> <tr>{$r[content]}</tr> </td> {/loop} {/pc}
11、父级单页面内容编辑:
phpcms/modules/content目录下的content.php:
$strs2 = "<span class='folder'>\$catname</span>"; 改为: $strs2= "<span class='folder'>\$add_icon<a href='?m=content&c=content&a=\$type&menuid=".$_GET['menuid']."&catid=\$catid' target='right'onclick='open_list(this)'>\$catname</a></span>";
phpcms/modules/content目录下的creat_html.php:
注释掉此行内容:$r['disabled'] = $r['child'] ? 'disabled' : '';
12、调用点击量不能少的引用:
<script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script>
13、表单向导验证码:
前台显示:
{php pc_base::load_sys_class('form', '', 0); } <input type="text" id="code" name="code" value="" defvalue="" tips="验证码" required="true"> {form::checkcode('code_img', '4', '14', 100, 30)}
后台启动验证码验证:
(/phpcms/moudles/formguide/index.php 文件 if (isset($_POST['dosubmit'])) 判断中加入如下代码,进入if判断后立即加验证码判断)
//启动session $session_storage = 'session_'.pc_base::load_config('system','session_storage'); pc_base::load_sys_class($session_storage); //验证码 if (($_SESSION['code'] != strtolower($_POST['code'])) || empty($_SESSION['code'])) { showmessage("验证码错误"); } else { $_SESSION['code'] = ''; }
14、栏目描述:
$CATEGORYS[$catid][description]}
15、列表页文章点击量
{php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$r[id])); $views = $_r[views]; } {$views}
16、文章搜索
sql="select * from v9_news where title like '%内容%%文章%'"
17、栏目分类筛选(sex,heihgt,weight:为选项字段)
{php $sexid=$_GET['sex'] or $sexid='sex'} {php $heightid=$_GET['height'] or $heightid='height'} {php $weightid=$_GET['weight'] or $weightid='weight'} {if $sexid=='sex' && $weightid=='weight' && $heightid=='height'} {pc:content action="lists" catid="$catid" order="id desc" num="10"} <!---{count($data)}---> {else} {php $where=" sex=$sexid and height=$heightid and weight=$weightid "} {pc:content action="lists" catid="$catid" where="$where" order="id DESC" num="10"} {/if} {loop $data $r} <li><a href="{$r[url]}">{$r[title]}</a></li> {/loop} {/pc}
18、文章全站排行榜调用:
{pc:get sql="SELECT DISTINCT url,title,views FROM v9_news,v9_hits WHERE v9_news.id = substring(v9_hits.hitsid,5) ORDER BY v9_hits.views DESC" num="10" } <ul> {loop $data $v} <li><a href="{$v['url']}">{$v[title]}</a><span>点击数:{$v[views]}</span></li> {/loop} </ul> {/pc}
19、全站搜索
{php $str=$_GET['searchword']} {if $str} {pc:get sql="select * from v9_news where title like '%$str%'"} {loop $data $r} <li>{$r[title]}</li> {/loop} {/pc} {/if}