<a href=" " onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('{siteurl($siteid)}');">设为首页</a>phpcms加入收藏代码:
<a href="javascript:window.external.AddFavorite('{siteurl($siteid)}','{$SEO['site_title']}')">加入收藏</a>首页导航栏:
{pc:content action="category" catid="0" num="7" siteid="$siteid" order="listorder ASC"} <li {if empty($catid)}class="current"{/if}><a href="{siteurl($siteid)}"><span>首页</span></a></li> {loop $data $r} <li {if $r['catid'] == $catid || $CATEGORYS[$CAT[parentid]][catid]==$r['catid']}class="current" {/if}><a href="{$r[url]}"><span>{$r[catname]}</span></a></li> {/loop} {/pc}子栏目导航栏循环
<?php if(empty($CATEGORYS[$CAT[parentid]][catid])){ $mycatId = $catid; }else{ $mycatId = $CATEGORYS[$CAT[parentid]][catid]; } ?> {pc:content action="category" catid="$mycatId" num="25" siteid="$siteid" order="listorder ASC"} {loop $data $r} <li {if $r['catid'] == $catid || $top_parentid==$r['catid']}class="current"{/if}><a href="{$r[url]}">{$r[catname]}</a></li> {/loop} {/pc}首页最新文章列表
图片缩略图 {thumb($r[thumb],200,100,1)} 注:如果栏目从第二条开始调4条数据可以这样 {pc:content action="lists" catid="10" order="id desc limit 1,4--"} pc循环标签里面$n代表循环的次数 起始值从1开始的 如果文章只想调带缩略图可以加一个参数 thumb="1"
{pc:content action="lists" catid="10" order="id desc" num="6"} {loop $data $r} <li class="tr"><a href="{$r[url]}" target="_blank" class="fl" title="{$r[title]}" alt="{$r[title]}">{str_cut($r[title],72,'')}</a><span>{date('Y-m-d', $r[inputtime])}</span></li> //注:inputtime为发布时间,如果是updatetime为更新时间 {/loop} {/pc}参数说明{str_cut($r[title],72,'')} 截断标题,72代表字符长度,第三个参数为空代表如果标题没有显示全,后面什么都不显示,默认为“...”
当前栏目文章列表
{pc:content action="lists" catid="$catid" order="id" num=""} {loop $data $r} <a href="{$r[url]}" target="_blank">{$r[title]}</a> {/loop} {/pc}首页热门文章 按照点击数倒叙
{pc:content action="hits" catid="1" order="views DESC" moreinfo="1"} {loop $data $r} <a href="{APP_PATH}index.php?m=announce&c=index&a=show&aid={$r['aid']}">{$r['title']}</a> {/loop} {/pc}Phpcms竟然不支持调用全站文章排行。下午仔细研究了Phpcms源码,终于找到解决办法。
需要修改phpcms\modules\content\classes\content_tag.class.php文件,找到以下函数:
function hits($data){}
修改
SYS_TIME-intval($data['day'])*86400;
GET标签实现首页调用全站热门文章
{pc:get sql="select url,title,inputtime,dayviews FROM v9_news,v9_hits WHERE CONCAT('c-1-',v9_news.id)=v9_hits.hitsid order by views desc" num="10" siteid="$siteid"} {loop $data $r} <li><span class="num{$n}">{$n}</span><a href="{$r[url]}" title="{$r[title]}"{title_style($r[style])} target="_blank">{$r[title]}</a></li> {/loop} {/pc}其中c-1-中的1是模型ID,也可以实现自定义模型的,推荐大家使用。 一定要注意这里的c-1 很重要!!!
首页调用全站“日、周、月”点击排行的GET调用方法下面是实现首页调用全站的“日、周、月”点击排行的GET调用代码:
{pc:get sql="SELECT h.`weekviews`,n.`title`,n.`url`,n.`style` FROM `v9_hits` AS h,`v9_news` AS n WHERE substring_index(h.`hitsid`, '-', -1)=n.`id` AND n.`status`=99 ORDER BY h.`weekviews` DESC" num="9" cache="3600" day="7"} {loop $data $v} {if $n%2==1}<li>{else}<li class="bg">{/if}<a title="{$v[title]}" target="_blank" href="{$v[url]}">{str_cut($v['title'],200,'...')}</a><br /><span>点击:{number_format($v['weekviews'])}</span></li> {/loop} {/pc}
此代码是周点击排行,日点击和月点击只要替换三个weekviews和day="7"里面的7即可
48小时点击:dayviews、day=2本月点击:monthviews、day=48
Phpcms V9 调用全站最新文章的方法:
修改\phpcms\modules\content\classes\content_tag.class.php,找到下面代码:
/** * 列表页标签 * @param $data */ public function lists($data) { $catid = intval($data['catid']); if(!$this->set_modelid($catid)) return false; if(isset($data['where'])) { $sql = $data['where']; } else { $thumb = intval($data['thumb']) ? " AND thumb != ''" : ''; if($this->category[$catid]['child']) { $catids_str = $this->category[$catid]['arrchildid']; $pos = strpos($catids_str,',')+1; $catids_str = substr($catids_str, $pos); $sql = "status=99 AND catid IN ($catids_str)".$thumb; } else { $sql = "status=99 AND catid='$catid'".$thumb; } } $order = $data['order']; $return = $this->db->select($sql, '*', $data['limit'], $order, '', 'id'); //调用副表的数据 if (isset($data['moreinfo']) && intval($data['moreinfo']) == 1) { $ids = array(); foreach ($return as $v) { if (isset($v['id']) && !empty($v['id'])) { $ids[] = $v['id']; } else { continue; } } if (!empty($ids)) { $this->db->table_name = $this->db->table_name.'_data'; $ids = implode('\',\'', $ids); $r = $this->db->select("`id` IN ('$ids')", '*', '', '', '', 'id'); if (!empty($r)) { foreach ($r as $k=>$v) { if (isset($return[$k])) $return[$k] = array_merge($v, $return[$k]); } } } } return $return; }修改成下面代码:
/** * 列表页标签 * @param $data */ public function lists($data) { $catid = intval($data['catid']); if(isset($data['where'])) { $sql = $data['where']; } else { $thumb = intval($data['thumb']) ? " AND thumb != ''" : ''; if(!empty($catid)) { if(!$this->set_modelid($catid)) return false; if($this->category[$catid]['child']) { $catids_str = $this->category[$catid]['arrchildid']; $pos = strpos($catids_str,',')+1; $catids_str = substr($catids_str, $pos); $sql = "status=99 AND catid IN ($catids_str)".$thumb; } else { $sql = "status=99 AND catid='$catid'".$thumb; } } else { $sql = "status=99".$thumb; } } $order = $data['order']; $return = $this->db->select($sql, '*', $data['limit'], $order, '', 'id'); //调用副表的数据 if (isset($data['moreinfo']) && intval($data['moreinfo']) == 1) { $ids = array(); foreach ($return as $v) { if (isset($v['id']) && !empty($v['id'])) { $ids[] = $v['id']; } else { continue; } } if (!empty($ids)) { $this->db->table_name = $this->db->table_name.'_data'; $ids = implode('\',\'', $ids); $r = $this->db->select("`id` IN ('$ids')", '*', '', '', '', 'id'); if (!empty($r)) { foreach ($r as $k=>$v) { if (isset($return[$k])) $return[$k] = array_merge($v, $return[$k]); } } } } return $return; }调用代码如下:
{pc:content action="lists" num="10" order="id DESC" cache="3600"}phpcmsV9同时调用多个栏目的文章标签
{pc:get sql="SELECT `n`.`inputtime`,`n`.`url`,`n`.`title`,`c`.`catname`,`c`.`url` as `c_url` FROM `v9_news` as `n` left join `v9_category` as `c` on `n`.`catid` = `c`.`catid` where `c`.`catid` in (6,7,8,9,10) order by `n`.`id` desc" num="10" cache="3600" page="" dbsource="" return="data"} {loop $data $key $val} <li><span class="right">{date('Y-m-d H:i:s',$val[inputtime])}</span>[<a href="{$val[c_url]}" target="_blank">{$val[catname]}</a>] <a href="{$val[url]}" title="{$val[title]}" target="_blank">{$val[title]}</a></li> {/loop} {/pc}参数说明:`catid` in (6,7,8,9,10) 这里的数字即为调用的多个栏目的ID
首页图片列表
{pc:content action="position" posid="" thumb="1" order="listorder DESC" num=""} <ul class="content news-photo picbig"> {loop $data $r} <li> <div class="img-wrap"> <a href="{$r[url]}" title="{$r[title]}"><img src="{thumb($r[thumb],110,0)}" title="{$r[title]}"/></a> </div> <a href="{$r[url]}" title="{$r[title]}">{str_cut($r[title],20)}</a> </li> {/loop} </ul> {/pc}首页友情链接 后台模块友情链接处修改
申请友情链接:
<a href="{APP_PATH}index.php?m=link&c=index&a=register&siteid={$siteid}">申请链接</a>友情链接列表方法1:
{pc:link action="type_list" siteid="$siteid" order="listorder DESC" num="10" return="dat"} {loop $dat $v} {if $type==0} <a href="{$v[url]}" target="_blank">{$v[name]}</a> | {else} <a href="{$v[url]}" target="_blank"><img src="{$v[logo]}" width="88" height="31" style="border: 1px solid #FFBE7A;"></a> {/if} {/loop} {/pc}友情链接列表2:
{pc:link action="type_list" siteid="$siteid" linktype="0" order="listorder DESC" num="8" return="pic_link"} {loop $pic_link $v} <a href="{$v['url']}" title="{$v["name']}" target="_blank">{$v[name]}</a> | {/loop} {/pc}参数说明:linktype如0代表文字链接 如果为1代表图片链接。可以在后台添加友情连接处查看源代码,发现name=“linktype” value=“0或者1”
首页广告位推荐
{pc:content action="position" posid="12" order="id DESC" num="1"} {loop $data $r} <li class="tr"><a href="{$r[url]}" title="{$r[title]}" alt="{$r[title]}" class="fl">{$r[title]}</a> <span>{date('Y-m-d H:i:s',$r[inputtime])}</span></li> {/loop} {/pc}