首页调用栏目 {pc:content action="category" siteid="$siteid" num="15" order="listorder"} {loop $data $r} <li><a title="" href="{$r[url]}">{$r[catname]}</a></li> {/loop} {/pc} 调用二级栏目 {pc:content action="category" catid="7" num="20" order="listorder"} {loop $data $r} <a href="{$r[url]}" target="_blank" title="{$r[title]}">{$r[catname]}</a> {/loop} {/pc} 判断当前栏目是否存在子栏目 {if $v[child]==1} XXX {else} XXX {/if} 调用文章列表 {pc:content action="lists" catid="25" num="8" order="id desc"} {loop $data $r} <li><a href="{$r[url]}" target="_blank" title="{$r[title]}">{$r[title]}</a></li> {/loop} {/pc} 带缩略图: {pc:content action="lists" catid="20" order="id desc" num="6"} {loop $data $r} <div class="tuphp"> <h4><a href="{$r[url]}" target="_blank" title="{$r[title]}"> <img src="{thumb($r['thumb'],111,139)}" alt="{$r[title]}" width="" height="" border="0"></a></h4> <p><a href="{$r[url]}" target="_blank" title="{$r[title]}">{$r[title]}</a></p> </div> {/loop} {/pc} 调用推荐位 {pc:content action="position" posid="2" order="listorder" num="1"} {loop $data $r} <div class="abti"><a href="{$r[url]}" target="_blank" title="{$r[title]}">{$r[title]}</a></div> <div class="aboutcon"> <img src="statics/dimages/2010111758232601.jpg">{str_cut($r[description],106)} <div style="clear:both;"></div> </div> <div class="abobtn"><a href="{$r[url]}" target="_blank" title=""><img src="statics/dimages/abobtn.jpg"></a></div> {/loop} {/pc} sql方法调用 {pc:get sql="SELECT * FROM v9_news WHERE catid <= 50 and catid >= 1 order by id DESC" return="data" num="6" start="0" } {loop $data $r} <li><a href="{$r[url]}" target="_blank" class="lef" title="{$r[title]}">{str_cut($r[title],35,'')}</a><span>[{date('Y-m-d',$r[inputtime])}]</span></li> {/loop} {/pc} 调用相关文章 {pc:content action="relation" relation="$relation" catid="2" num="5" keywords="$rs[keywords]"} {loop $data $r} {$r[title]} {/loop} {/pc} 内容页相关文章的点击量 {pc:content action="lists" catid="$catid" num="10" order="id DESC" page="$page"} {loop $data $r} <p> <li><a href="{$r[url]}" target="_blank"><img src="/NanJing454/statics/nimages/next1.png" /> {str_cut($r[title], 57)}</a>{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} </li> </p> {/loop} {/pc} 全站最新文章 {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} 合作机构: {pc:link action="type_list" linktype="1" siteid="$siteid" typeid="53" num="16" order="listorder DESC"} {loop $data $r} <img src="{$r['logo']}" border="0" /> {/loop} {/pc} 友情链接: {pc:link action="type_list" siteid="$siteid" typeid="53" order="listorder DESC" num="60" return="dat"} {loop $dat $v} <a href="{$v[url]}" target="_blank" title="{$v[name]}">{$v[name]}</a> {/loop} {/pc} {date('Y-m-d',$r[inputtime])} {str_cut($r[title],30,'')} 列表页调父栏目子栏目{php $arrchildid = $CATEGORYS[$CAT[parentid]][catid]} {pc ... catid="$arrchildid"} 内页时间:{date('Y-m-d',strtotime($inputtime))} 导航条 当前位置 ><a href="{siteurl($siteid)}"> 首页 </a>><font color="#6C4833"> {catpos($catid)} {$title}</font> 上一篇:<a href="{$previous_page[url]}">{str_cut($previous_page[title], 30)}</a> 下一篇:<a href="{$next_page[url]}">{str_cut($next_page[title], 30)}</a> 时间:date('Y-m-d',$r[inputtime])} <script type="text/javascript" src="{JS_PATH}jquery.min.js"></script> 内容页调取浏览次数:</span><span id="hits"><script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script></span> 列表页调取浏览次数 {php $db = pc_base::load_model('hits_model’); $_r = $db->get_one(array('hitsid’=>’c-’.$modelid.’-’.$r[id])); $views = $_r[views]; } 点击:{$views} 列表页调关键词: {php $keywords=explode(' ', $r['keywords'])} {loop $keywords $keyword} <a href="{APP_PATH}index.php?m=content&c=tag&catid={$catid}&tag={urlencode($keyword)}" class="blue">{$keyword}</a> {/loop} 内页调关键词:{loop $keywords $keyword}<a href="{APP_PATH}index.php?m=content&c=tag&catid={$catid}&tag={urlencode($keyword)}" class="blue">{$keyword}</a> {/loop} 加载附表 moreinfo="1" js获取时间 <script> var x = new Date(); var shijian = x.toLocaleString().substring(0,10) ; document.write(shijian); </script> 调用单网页 {pc:get sql="SELECT * FROM phpcms_page where catid=16" cache="3600" return="data"} {loop $data $r} <div id="Article"> <h1>{$r[title]}</h1> <div class="content"> {$r[content]} </div> </div> {/loop} {/pc} 栏目页循环栏目 {loop subcat($catid) $v} {php if($v['type']!=0) continue;} <div class="main_list_box"> <div class="list_tit"> <h5><em></em> {$v[catname]}</h5> <a href="{$v[url]}" class="more">更多</a></div> <ul class="main_list_ul"> {pc:content action="lists" catid="$v[catid]" num="4" order="id DESC"} {loop $data $r} <li><span><a href="{$r[url]}">{$r[title]} </a></span><em>{date('Y-m-d',$r[inputtime])}</em></li> {/loop} {/pc} </ul> </div> {$j++} {php if ($j>=7) break;} {/loop} 栏目名调用: $CATEGORY[$catid][catid] 栏目id $CATEGORY[$catid][module] 栏目所在的模块 $CATEGORY[$catid][type] 栏目类型 $CATEGORY[$catid][modelid] 栏目所属模型id $CATEGORY[$catid][catname] 栏目名称 $CATEGORY[$catid][style] 栏目名称样式 $CATEGORY[$catid][image] 栏目图片 $CATEGORY[$catid][catdir] 栏目路径 $CATEGORY[$catid][url] 目录url $CATEGORY[$catid][parentid] 栏目的父id $CATEGORY[$catid][arrparentid] 所有上级栏目ID $CATEGORY[$catid][parentdir] 父栏目的路径 $CATEGORY[$catid][child] 是否有子栏目 $CATEGORY[$catid][arrchildid] 栏目的所有子栏目id $CATEGORY[$catid][items] 栏目信息数 $CATEGORY[$catid][ismenu] 栏目是否显示导航 搜索页调用栏目名 {pc:get sql="select * from v9_category where catid='$r[catid]'" num="1" return="da"} {loop $da $v} <a href="{$v[url]}" >{$v[catname]}</a> {/loop} {/pc} 调用最新文章,带所在版块{pc:get sql="SELECT a.title, a.catid, b.catid, b.catname, a.url as turl ,b.url as curl,a.id FROM `v9_news` a, `v9_category` b WHERE a.catid = b.catid ORDER BY `a`.`id` DESC "num="15" cache="300"} 3.多栏目调用&多推荐位调用调用需求:文章范围为59 60 61三个栏目,并且推送到了27 和28两个推荐位;从第三条开始,连续调用7篇文章。 4.显示栏目名称(只是名称,不带链接){$catname} 5.获取父栏目id/获取父栏目名称{$CATEGORY[$catid][parentid]} 6.外部数据源调用dedecmsdb 在后台数据源处添加{pc:get sql="SELECT * FROM cq_member where mtype='企业' " cache="3600" dbsource="dedecmsdb"num="7" return="data"} 7.调用子栏目(在栏目首页模板需要用到){pc:content action="category" catid="$catid" num="25" siteid="$siteid" order="listorderASC"} 8.显示指定id的栏目名称 (例子这里catid=22){$CATEGORYS[22]['catname']} 9.在文章面前显示文章类别{pc:content action="lists" catid="79" order="listorder DESC" num="14" } 10.指定变量循环增长(幻灯片经常用到) 11.文章调用使用limit{pc:content action="position" posid="36" num="1" order="listorder DESC limit 1,1--" } 12.文章从指定位置开始调用起始位置为5,调用3条。相当于limit功能。 13.文章列表页调用关键字,或者首页调用关键字注意:explode(',',$r[keywords]);是将文章关键词通过英文逗号分离,也就是说每一篇文章都要以逗号间隔关键字,否则调用出来会 是全部作为一个关键字。如果是空格间隔关键字,将explode(',',$r[keywords]);改成explode(' ',$r[keywords]);{pc:content action="lists" catid="$catid" num="10" order="id DESC" page="$page"} 14.每当列表几行的时候出现一次某些符号(比如首页里面的文章推荐,一行显示两条,在这两条中间想加一条竖线 | 就用到这个代码了)数量大的话就容易出错,因为模运算嘛~~呵呵 不过一般也就4个标题以下{pc:content action="position" posid="8" order="listorder DESC" num="2"} 15.v9 列表页完美支持自定义段调用{pc:content action="lists" catid="$catid" num="25" order="id DESC" page="$page"moreinfo="1"} 16.当前栏目调用父级及以下栏目信息方法其他代码 该咋地还是要咋地 。这是要素{php $arrchildid = $CATEGORYS[$CAT[parentid]][arrchildid]} 17.V9表单功能 提交之后如何返回当前页面,而不是默认的首页文件地址找到 phpcms\modules\formguide\index.php文件第73行showmessage(L('thanks'), APP_PATH);修改成 如下代码即可实现自动返回前一页showmessage(L('thanks'), HTTP_REFERER);18.v9 首页或分页自定义字段调用和15差不多第一普通列表或栏目调用自定义字段在{pc:content action="lists" 后加上副表moreinfo=1 (等于1时显示,0时不显示)例子: 第二种推荐位调用自定义字段在模型里加好自定义字段后,必须把“在推荐位标签中调用”点击“是“然后用同一样的方法去调节数据就OK了,记住,如果你加了文章,必须去更新文章才会显示,自定义段在推荐中只显示你选择后,选择前加的加文章不显示,更新一下文章就显示了例子: 20.编辑器上传图片自动使用标题作为alt参数一: 修改 statics/js/ckeditor/plugins/image/dialogs/image.js找到accessKey:'T','default':'' 22、PHPCMS V9的get标签调用1、调用本系统单条数据,示例(调用ID为1的信息,标题长度不超过25个汉字,显示更新日期): 3、带分页,示例(调用栏目ID为1通过审核的10条信息,标题长度不超过25个汉字,显示更新日期,带分页): 4、自定义返回变量,示例(调用栏目ID为1通过审核的10条信息,标题长度不超过25个汉字,显示更新日期,返回变量为 $v): 5、调用同一账号下的其他数据库,示例(调用数据库为bbs,分类ID为1的10个最新主题,主题长度不超过25个汉字,显示更新日期): 6、调用外部数据,示例(调用数据源为bbs,分类ID为1的10个最新主题,主题长度不超过25个汉字,显示更新日期): |
|