首页 技术 正文
技术 2022年11月13日
0 收藏 660 点赞 3,724 浏览 5456 个字

一、SEO优化:

获取栏目的关键字:{$SEO['keyword']}
获取栏目的描述:{$SEO['description']}
判断栏目的title是否存在或为空,如果是的话,则用站点的title替代 :
{if isset($SEO['title']) && !empty($SEO['title'])}{$SEO['title']}{/if}{$SEO['site_title']}

二、模板加载:

{template "content" , "header_index"}
* header_index 要加载的模板名称。
* 该标签只能加载自定义的模板,对于预定义好的模板是不能进行加载的。
* 预定义的模板名称:
category_ 栏目页模板的名称都是如此命名
list_列表页的模板都是如此命名
article_内容页的模板都是如此命名
index.html首页模板的命名
default.html超首模板的命名
page_ 单页面的模板都是如此命名
show_ 内容页都是如此命名

三、PC 内容查询标签:

一般格式的查询:
{pc:content action="lists" catid="$catid" num="5" order="listorder,id DESC" page="$page" thumb="1" start="5"}
{loop $data $r}{/loop}
{/pc}* action 规定生成的动作,默认的是lists。如果取值 为position,表示读取推荐位中内容。那么catid就要改成了posid。
* catid 栏目ID,规定从哪个栏目中抽取数据。
* num 表示生成的数据条目的数量。
* order 表示排序的方式,DESC为降序,ASC为升序。
* page 如果指定了改属性,表示有分页。最终的分页数据则有分页标签进行调用。
* thumb 表示内容是否有缩略图。
* start 表示起始的位置。万能查询语句:
万能查询实际上就是PC标签+SQL语言来直接对数据表进行查询。
{pc:get sql="select catname from v9_category where catid='$catid'" return "data"}
{loop $data $r}
{/loop}
{/pc}* sql 中保存的是要执行的SQL语句。
- catname 要查询的字段
- v9_category 表名
- catid 记录的关键字段。
* data中保存的是返回到的数据,这些数据都会以一个数组的形式保存到$data中,然后以$r[catname]的方式进行调用。

四、页面相关的常用标签:

{siteurl($siteid)}   显示首页的URL地址。
{$catid} | {$CAT[catid]} 显示当前栏目的ID。
{$catname} | {$CAT[catname]} 显示栏目的名称(中文)。
{$catdir}| {$CAT[catdir]} 显示栏目的名称(英文)。
{$parentid} 拿到父栏目的id
{$top_parentid} 拿到顶级栏目的id
{$inputtime} 拿到文章输出时间
{$title} 拿到文章的标题
{$id}        拿到文章的文章ID
{$modelid} 拿到模型的模型ID{catpos($catid)} 显示面包屑导航。
{$content} 加载内容。
{$page} 显示分页。*注:{ } 该符号专用于页面展示标签数据时使用。运算判断无需添加。=========== 依附于有数据 $data的标签 ================
{$r[title]} 显示文章的标题。
{str_cut($r[title],30,'.....')} 显示裁剪后的标题。
{$r[url]} 显示文章的链接。
{$r[thumb]} 显示文章的缩略图。
{$r[style]} 拿到内嵌样式
{thumb($r[thumb],90,90)} 显示裁剪后的缩略图。
{date("y-m-d h:m:s",$r[inputtime])} 格式化时间输出。

五、广告位调用:

{loop $pinfo $p}
document.write('<li><a href="{$p['setting'][1]['linkurl']}" rel="external nofollow" rel="external nofollow" class="fl" target="_blank">{$p['name']}</a><em class="fr">{$p['setting'][1]['title']}</em></li>');
{/loop}{loop $pinfo $p}
document.write('<a href="{$p['setting'][1]['linkurl']}" rel="external nofollow" rel="external nofollow" target="_blank" title="{$p['setting'][1]['alt']}"><img src="{$p['setting'][1]['imageurl']}" alt="{$p['setting'][1]['alt']}"
     height="{$height}" width="{$width}"/></a>');
{/loop}

六、基础语法:

定义变量 {php $num=0}
* 注意有些变量是系统自定义的,例如:$catid 、$CATEGORYS 、$parentid 等。
判断 {if $num==0}
双分支判断 {if $num==0} {else} {/if}
结合变量来控制列表生成数量:
{php $num=0}
{pc:content action="lists" catid="67" num="30" order="listorder , id DESC" page="$page"}
{loop $data $r}
{php $num++}
<li> <a href="{$r[url]}" rel="external nofollow" rel="external nofollow" target="_blank">{$r{title}}</a></li>
{if $num%5==0}<hr />{/if}
{/loop}
{/pc}

七、实例与技巧:

#1 loop中拿到文章的属性:

{pc:content  action="position" posid="14" order="listorder DESC,id DESC" num="5"}
{loop $data $r}
$r[catid] //当前文章所属栏目id
$r[catdir] // 当前文章所属栏目英文名称
$r[catname] //当前文章所属栏目中文名称{/loop}
{/pc}

#2 PC标签的三种用处:

循环列表:
{pc:content action="lists" catid = }
循环推荐位
{pc:content action="position" posid = }
循环栏目:
{pc:content action="category" catid=}

#3 根据栏目名称获得栏目ID

<?php
$result = array();
$catList = array();
foreach ($CATEGORYS as $key=>$val) {
foreach ($val as $key1=>$val1) {
if($key1 == 'catdir'){
$result[$key] = $val[$key1];
}
}
}
foreach ($result as $a=>$val){
$catList[$val] = (String)$a;
}
?>
//调用方法:$catList['categoryName']

#4 CATEGORYS数组实例使用

* explode -- 将字符串转换为数组
* empty -- 判断是否为空
* array_keys -- 以参数数组的“键”组成一个新的数组返回。
* end -- 返回数组最后一个数组元素。<ul class="clearfix gamedata-list">
<?php
$strchildid = $CATEGORYS[$catid]['arrchildid'];
$arrchildid = explode(',',$strchildid);
if(!empty($arrchildid)){
foreach($arrchildid as $v){
if($v == $catid) {
countinue;//过滤自己
}else if($CATEGORYS[$v]['parentid'] != $catid){
countinue;//过滤非直接子类
}else{
?>
<li class="tit newplayer nl_{$CATEGORYS[$v]['catdir']}"><span></span>{$CATEGORYS[$v]['catname']}</li>
<li class="main-text">
<?php
$strchildid2 = $CATEGORYS[$v]['arrchildid'];
$arrchildid2 = explode(',',$strchildid2);
if(!empty($arrchildid2)){
foreach($arrchildid2 as $v2){
if($v2 == $v) {
countinue;//过滤自己
}else{
?><dl>
<dt><span></span>{$CATEGORYS[$v2]['catname']}:</dt>
<dd>
{pc:content action="lists" catid="$v2" num="20" order="listorder DESC,id DESC"}
{php $e= end(array_keys($data))}
{loop $data $key $r}
<a href="{$r[url]}" rel="external nofollow" rel="external nofollow" target="_blank">{$r[title]}</a>
{if $key != $e}
<span>|</span>
{/if}
{/loop}
{/pc}
</dd>
</dl><?php
}
}
}
}
}
}
?>
</li>
</ul>

#5 pc标签使用示例

<div class="gamedata-content">
{pc:content action="category" catid="$catList['gamedata']" order="listorder DESC" num ="100" }
{loop $data $r}
<h3 class="gamedata-title">{$r[catname]}</h3>
<ul class="gamedata-content-list">
{pc:content action="category" catid="$r[catid]" order="listorder DESC" num="500" }
{loop $data $s}
<li>
<dl class="clearfix">
<dt>{$s[catname]}<i></i></dt>
<dd>
{pc:content action="lists" catid="$s[catid]" num="1000" order="listorder,id DESC"}
{php $e= end(array_keys($data))}
{loop $data $key $v}
<a href="{$v[url]}" rel="external nofollow" target="_blank">{$v[title]}</a>
{if $key != $e}
<span>|</span>
{/if}
{/loop}
{/pc}
</dd>
</dl>
</li>
{/loop}
{/pc}
{/loop}
{/pc}
</div>

八、CATEGORYS 常用命令:

$CATEGORYS(栏目命令) 标签
$CATEGORYS是一个二维数组,它用于保存当前栏目的相关信息。
$CATEGORYS[65][catname]返回指定栏目的栏目名称
$CATEGORYS[$catid][catid] 栏目ID
$CATEGORYS[$catid][module] 栏目所在的模块
$CATEGORYS[$catid][type] 栏目类型
$CATEGORYS[$catid][modelid] 栏目所属模型id
$CATEGORYS[$catid][catname] 栏目名称
$CATEGORYS[$catid][style] 栏目名称样式
$CATEGORYS[$catid][image] 栏目图片
$CATEGORYS[$catid][catdir] 栏目路径
$CATEGORYS[$catid][url] 目录url
$CATEGORYS[$catid][parentid] 栏目的父id
$CATEGORYS[$catid][arrparentid] 所有上级栏目ID
$CATEGORYS[$catid][parentdir] 父栏目的路径
$CATEGORYS[$catid][child] 是否有子栏目
$CATEGORYS[$catid][arrchildid] 栏目的所有子栏目id
$CATEGORYS[$catid][items] 栏目信息数
$CATEGORYS[$catid][ismenu] 栏目是否显示导航
{$CATEGORYS[$catid][description]} 栏目描述
{$CATEGORYS[$catid][hits]} 栏目点击数
{$CATEGORYS[$parentid][catid]} 父栏目ID
{$CATEGORYS[$parentid][catname]} 父栏目名称
{$CATEGORYS[$top_parentid][catid]} 顶级栏目ID
{$CATEGORYS[$CATEGORYS[$CAT[parentid]][parentid]][catname]} 上上级栏目名称
{$CATEGORYS[$CATEGORYS[$CAT[parentid]][parentid]][url]} 上上级栏目链接
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,491
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,493
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,132
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,294