欢迎来到做网站吧,请先 登录注册

教程观看记录

资源投稿 | 网站地图 | 联系我们 | 收藏本站 |

做网站吧 > 图文教程 > PHPCMS教程 >
收 藏
1800

PHPCMS V9 TAG静态页面实现教程

所属栏目:PHPCMS教程 来源:未知 内容发布:做网站吧

下面是步骤(注:只做了TAG首页的列表的静态,TAG内容列表的没做):
1、先安装“世界首富”的TAG插件,网上可以搜到。因为我们要用和的tags表,PHPCMS的tag表数据统计不太理想,所以不用

2、修改:\phpcms\modules\content\tag.php

<?php
defined('IN_PHPCMS') or exit('No permission resources.');
//模型缓存路径
define('CACHE_MODEL_PATH',CACHE_PATH.'caches_model'.DIRECTORY_SEPARATOR.'caches_data'.DIRECTORY_SEPARATOR);

pc_base::load_app_func('util','content');
class tag {
        private $db;
        function __construct() {
                $this->db = pc_base::load_model('tags_model');
                $this->db_content = pc_base::load_model('tags_content_model');
                $this->db_recom = pc_base::load_model('tags_content_recom');
               
                /*$this->db = pc_base::load_model('content_model');
                $this->keyword_db = pc_base::load_model('keyword_model');*/
                $this->siteid = get_siteid();
        }
       
        public function init() {
                if(isset($_GET['siteid'])) {
                        $siteid = intval($_GET['siteid']);
                } else {
                        $siteid = 1;
                }
                $siteid = $GLOBALS['siteid'] = max($siteid,1);
                define('SITEID', $siteid);
                $_userid = $this->_userid;
                $_username = $this->_username;
                $_groupid = $this->_groupid;
                //SEO
                $SEO = seo($siteid);
                $sitelist  = getcache('sitelist','commons');
                $default_style = $sitelist[$siteid]['default_style'];
                $CATEGORYS = getcache('category_content_'.$siteid,'commons');
                $page = max($_GET['page'], 1);
                /*$pagesize = 20;
                $where = '`siteid`='.$this->siteid;
                $infos = $this->keyword_db->listinfo($where, '`id` DESC', $page, $pagesize);
                $pages = $this->keyword_db->pages;*/
                $tagdata = $this->db->listinfo('','tagid desc', $page, 248);
                $pages = pages($total,$page,10,URLRULE,array(),10) ;
                $total = $this->db->number;
                $numbers = ceil($total/248);
                $pages = $this->db->pages;
               
                $pages = str_replace("index.php?m=content&c=tag","tags/index_",$pages);
                for($tai = 1; $tai<=$numbers; $tai++){
                        if($tai>1){
                                $pages = str_replace("&page=".$tai,$tai.".html",$pages);
                        }
                }               
                include template('content', 'tag');
        }

        /**
         * 按照模型搜索
         */
        public function lists() {
                if(isset($_GET['siteid'])) {
                        $siteid = intval($_GET['siteid']);
                } else {
                        $siteid = 1;
                }
                $siteid = $GLOBALS['siteid'] = max($siteid,1);
                define('SITEID', $siteid);
                $_userid = $this->_userid;
                $_username = $this->_username;
                $_groupid = $this->_groupid;
                //SEO
                $SEO = seo($siteid);
                $sitelist  = getcache('sitelist','commons');
                $default_style = $sitelist[$siteid]['default_style'];
                $CATEGORYS = getcache('category_content_'.$siteid,'commons');
               
                $tag = $_GET['tag'];
                $models = getcache('model', 'commons');
                $i=0;
                $siteid = intval($_GET['siteid']);
                $modelid = intval($_GET['modelid']);
                $orderby = intval($_GET['orderby']);
                foreach($models as $model_v){
                        $model_arr .= 'model_arr['.$i++.'] = new Array("'.$model_v['modelid'].'","'.$model_v['name'].'","'.$model_v['siteid'].'");'."\n";
                }
                $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1;

                if($tag){
                        if($this->db->get_one(array('tag'=>$tag))){
                                $sql_arr = array('tag'=>$tag);
                                if($siteid){
                                        $sql_arr['siteid'] = $siteid;

                                }
                                if($modelid){
                                        $sql_arr['modelid'] = $modelid;
                                }
                                if($orderby){
                                        $sql_ord = 'updatetime desc';
                                }else{
                                        $sql_ord = 'updatetime asc';
                                }
                                $tagdata = $this->db_content->listinfo($sql_arr,$sql_ord, $page, 1);
                                $pages = $this->db_content->pages;
                                $total = $this->db_content->number;
                        }else{
                                showmessage('标签不存在!');
                        }
                }
               
                $SEO = seo($siteid, '', $tag);
                include template('content','tag_list');
        }
}
?>


3、修改 \phpcms\templates\default\content\tag.html和tag_list.html中的LOOP循环
    tag.html的-----------------------------------------
{loop $tagdata $r}
                <div class="tags_list_cutom">
                        <a href="{APP_PATH}index.php?m=content&c=tag&a=lists&tag={urlencode($r['tag'])}">{$r['tag']}</a>({$r['usetimes']})
                </div>
{/loop}
tag_list.html的————————————
{loop $tagdata $r}
        <div class="tags_tag_list">
                <div class="tags_tag_list_title">
                        <a href="{$r[url]}" target="_blank"{title_style($r[style])}>{$r[title]}</a>
                </div>
                <div class="tags_tag_list_time">
                        {date('Y-m-d H:i:s',$r[inputtime])}
                </div>
                <div class="clear"></div>
        </div>
{/loop}

4、在\phpcms\modules\content\create_html.php中添加方法
/**
        * 生成TAG标签页
        */
        public function tags() {
                $this->db = pc_base::load_model('tags_model');
                $this->db_content = pc_base::load_model('tags_content_model');
                $this->db_recom = pc_base::load_model('tags_content_recom');
                if(isset($_POST['dosubmit'])) {
                        extract($_POST,EXTR_SKIP);
                        $this->html = pc_base::load_app_class('html');
                        //判断目录是否存在
                        //$tags_dir = "tags/56.jpg";
                        $tags_dir = "tags/";
                        if(!is_dir($tags_dir)){
                                mkdir($tags_dir,0777,true);
                                //$message = L('dir_you_tags');
                        }
                        $tagdata = $this->db->listinfo('','tagid desc', $page, 248);
                        //$message = print_r($tagdata);
                       
                        $tags_number = $this->db->number;
                        $numbers = ceil($tags_number/248);
                        for($tai = 1; $tai<=$numbers; $tai++){
                                if($tai<=1){
                                        $content = file_get_contents("http://www.你的网址.cn/index.php?m=content&c=tag&page=1");
                                        $file = fopen($tags_dir."index.html","w");
                                }else{
                                        $content = file_get_contents("http://www.你的网址.cn/index.php?m=content&c=tag&page=".$tai);
                                        $file = fopen($tags_dir."index_".$tai.".html","w");
                                }
                                fwrite($file, $content);//读入页面
                        }
                        fclose($file);
                       
                        $forward = "?m=content&c=create_html&a=tags";
                       
                        $message = L('start_update_tags');
                        showmessage($message,$forward);
                }
                include $this->admin_tpl('create_html_tags');
        }
5、\phpcms\languages\zh-cn\content.lang.php中加

$LANG['start_update_tags'] = '开始更新TAG标签 ...';
$LANG['dir_you_tags'] = '当前目录不存在...';

6、在 menu 表中 加入
     name:       create_tags_html
     parentid:   873
     m          :    content
     c            :    create_html
     a            :    tags
     data       :    空
      listorder   :     0
    display    :    1
    project1到project5:    1 

织梦二次开发QQ群

群号(383578617) DedeCMS织梦教程QQ群 如果您有任何织梦问题,请把问题发到群里,群主将免费为您写解决教程!更多织梦模板、织梦插件、织梦教程请移步http://www.lol9.cn

文章关键词:PHPCMS V9  TAG静态  静态页面  

上一篇:没有了 下一篇:phpcms统计所有文章(今天文章)总数方法
相关推荐
网友评论
评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
上一篇:没有了
下一篇:phpcms统计所有文章(今天文章)总数方法

返回顶部