麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > CMS > PhpCMS > 正文

phpcmsv9移動端頁面靜態化實現方法——功能實現

2024-09-10 07:17:18
字體:
來源:轉載
供稿:網友

1、欄目添加、編輯相關實現方法修改

這里只需修改一個文件 phpcms/models/admin/category.php

a.欄目添加方法處理

在 category.php 中找到 public function add() 方法,把 add 方法中的


if($_POST['info']['type']!=2) {
    //欄目生成靜態配置
    if($setting['ishtml']) {
        $setting['category_ruleid'] = $_POST['category_html_ruleid'];
    else {
        $setting['category_ruleid'] = $_POST['category_php_ruleid'];
        $_POST['info']['url'] = '';
    }
 
}
修改為:

if($_POST['info']['type']!=2) {
    //欄目生成靜態配置
    if($setting['ishtml']) {
        $setting['category_ruleid'] = $_POST['category_html_ruleid'];
    else {
        $setting['category_ruleid'] = $_POST['category_php_ruleid'];
        $_POST['info']['url'] = '';
    }
 
    //添加的內容
    //移動端生成靜態配置
    if ($setting['m_ishtml']){
        $setting['m_category_ruleid'] = $_POST['m_category_html_ruleid'];
    }else{
        $setting['m_category_ruleid'] = $_POST['m_category_php_ruleid'];
    }
}
 
//添加的內容
//移動端內容生成靜態配置
if($setting['m_content_ishtml']) {
    $setting['m_show_ruleid'] = $_POST['m_show_html_ruleid'];
else {
    $setting['m_show_ruleid'] = $_POST['m_show_php_ruleid'];
}

b.欄目編輯方法處理

在 category.php 中找到 public function edit() 方法,把 edit方法中的


//欄目生成靜態配置
if($_POST['type'] != 2) {
    if($setting['ishtml']) {
        $setting['category_ruleid'] = $_POST['category_html_ruleid'];
    else {
        $setting['category_ruleid'] = $_POST['category_php_ruleid'];
        $_POST['info']['url'] = '';
    }
}

修改為:

//欄目生成靜態配置
if($_POST['type'] != 2) {
    if($setting['ishtml']) {
        $setting['category_ruleid'] = $_POST['category_html_ruleid'];
    else {
        $setting['category_ruleid'] = $_POST['category_php_ruleid'];
        $_POST['info']['url'] = '';
    }
 
    //添加的內容
    //移動端生成靜態配置
    if ($setting['m_ishtml']){
        $setting['m_category_ruleid'] = $_POST['m_category_html_ruleid'];
    }else{
        $setting['m_category_ruleid'] = $_POST['m_category_php_ruleid'];
    }
}
 
//添加的內容
//移動端內容生成靜態配置
if($setting['m_content_ishtml']) {
    $setting['m_show_ruleid'] = $_POST['m_show_html_ruleid'];
else {
    $setting['m_show_ruleid'] = $_POST['m_show_php_ruleid'];
}

2、內容發布管理添加生成移動端內容頁、欄目頁功能

擴展——菜單管理——發布管理:添加子菜單

添加'批量更新移動端內容頁'菜單:
菜單中文名:批量更新移動端內容頁
英文名:create_content_html_m
模塊名:content
文件名:create_html
方法名:show_m
 
添加'批量更新移動端欄目頁'菜單:
菜單中文名:批量更新移動端欄目頁
英文名:create_list_html_m
模塊名:content
文件名:create_html
方法名:category_m

3、實現批量更新移動端內容頁

①方法修改

復制 phpcms/models/content/create_html.php 中的 show 方法放到 show 方法之后,把 show 方法改為 show_m ,
修改 $urls = $this->url->show($r['id'], '', $r['catid'],$r['inputtime']);為 $urls = $this->url->show_m($r['id'], '', $r['catid'],$r['inputtime']); (有2處)
修改 $this->html->show($urls[1],$r,0,'edit',$r['upgrade']); 為 $this->html->show_m($urls[1],$r,0,'edit',$r['upgrade']); (有2處)
 
在 phpcms/models/content/classes/url.class.php 中,復制 show 方法放到 show 方法之后,把 show 方法改為 show_m ,
修改 $content_ishtml = $setting['content_ishtml']; 為 $content_ishtml = $setting['m_content_ishtml'];
修改 $show_ruleid = $setting['show_ruleid']; 為 $show_ruleid = $setting['m_show_ruleid'];
修改 $url_arr['content_ishtml'] = 1; 為 $url_arr['m_content_ishtml'] = 1;
 
復制 phpcms/models/content/classes/html.class.php 中的 show 方法放到 show 方法之后,把 show 方法修改為 show_m,
修改 include template('content', $template); 為 include template('wap', $template);(wap為你應用的模板下存放移動站模板的文件夾名稱,這里如果不修改,生成的頁面用的是content里面的模板)

②模板修改

復制 phpcms/models/content/templates/create_html_show.tpl.php 文件到當前文件夾下,并重命名為 create_html_show_m.tpl.php 
修改 create_html_show_m.tpl.php 文件 form 表達提交方法 ?m=content&c=create_html&a=show 為 ?m=content&c=create_html&a=show_m
修改 create_html_show_m.tpl.php 文件下面 JavaScript 中的 ?m=content&c=create_html&a=show&modelid 為 ?m=content&c=create_html&a=show_m&modelid
 
再次修改 phpcms/models/content/create_html.php 中的 show_m 方法,把此方法中所有的 ?m=content&c=create_html&a=show 修改成 ?m=content&c=create_html&a=show_m 
修改此 show_m 方法末尾的模板應用 include $this->admin_tpl('create_html_show'); 為 include $this->admin_tpl('create_html_show_m');

4、實現批量更新移動端欄目頁

①方法修改

復制 phpcms/models/content/create_html.php 中的 category 方法放到原 category 方法后面,把 category 方法改為 category_m ,
修改 do..while 循環中的 $this->html->category($catid,$page); 為 $this->html->category_m($catid,$page);
 
復制 phpcms/models/content/classes/html.class.php 中的 category 方法放到 category 方法之后,把 category 方法修改為 category_m,
修改
if($parent_setting['ishtml']==0 && $setting['ishtml']==1){
    $parentdir = $CATEGORYS[$CAT['parentid']]['catdir'].'/';
}

if($parent_setting['m_ishtml']==0 && $setting['m_ishtml']==1){
    $parentdir = $CATEGORYS[$CAT['parentid']]['catdir'].'/';
}
修改 $base_file = $this->url->get_list_url($setting['category_ruleid'],$parentdir, $catdir, $catid, $page); 為 $base_file = $this->url->get_list_url($setting['m_category_ruleid'],$parentdir, $catdir, $catid, $page);
修改 include template('content',$template); 為 include template('wap',$template);(wap為你應用的模板下存放移動站模板的文件夾名稱,這里如果不修改,生成的頁面用的是content里面的模板)


②模板修改

復制 phpcms/models/content/templates/create_html_category.tpl.php 文件到當前文件夾下,并重命名為 create_html_category_m.tpl.php 
修改 create_html_category_m.tpl.php 文件 form 表達提交方法 ?m=content&c=create_html&a=category 為 ?m=content&c=create_html&a=category_m
修改 create_html_category_m.tpl.php 文件下面 JavaScript 中的 ?m=content&c=create_html&a=category&modelid 為 ?m=content&c=create_html&a=category_m&modelid
 
再次修改 phpcms/models/content/create_html.php 中的 category_m 方法,把此方法中所有的 ?m=content&c=create_html&a=category 修改成 ?m=content&c=create_html&a=category_m 
修改此 show_m 方法末尾的模板應用 include $this->admin_tpl('create_html_category'); 為 include $this->admin_tpl('create_html_category_m');

5、發布管理添加生成移動端首頁

擴展——菜單管理——發布管理:添加子菜單

添加 '生成移動端首頁' 菜單:
菜單中文名:生成移動端首頁
中文名:index_m
模塊名:content
文件名:create_html
方法名:public_index_m
復制 phpcms/models/content/create_html.php 中的 public_index 方法放到 public_index 方法之后 ,修改方法名為 public_index_m,
修改 $size = $this->html->index(); 為 $size = $this->html->index_m();
復制 phpcms/model/content/classes/html.class.php 中的 index 方法放到 index 方法之后,并重命名為 index_m,

修改后的index_m的方法內容如下:

public function index_m() {
 
        if($this->siteid==1) {
            $file = PHPCMS_PATH.'m/index.html';
            //添加到發布點隊列
            $this->queue->add_queue('edit','/m/index.html',$this->siteid);
        else {
            $site_dir $this->sitelist[$this->siteid]['dirname'];
            $file $this->html_root.'/'.$site_dir.'/m/index.html';
            //添加到發布點隊列
            $this->queue->add_queue('edit',$file,$this->siteid);
            $file = PHPCMS_PATH.$file;
        }
        define('SITEID'$this->siteid);
        //SEO
        $SEO = seo($this->siteid);
        $siteid $this->siteid;
        $CATEGORYS $this->categorys;
        $style $this->sitelist[$siteid]['default_style'];
        ob_start();
 
        include template('wap','index',$style);
 
        return $this->createhtml($file, 1);
    }

 到此移動端頁面靜態化基本完成了。當然了,這里只是實現頁面靜態化,對于生成的移動端頁面里面的 url 這里就不做介紹了,因此,按照我這里分享的教程,最后生成的移動端頁面里的 url 有可能是 pc 端的url,具體就要看你的模板是怎么處理的了。

另外,在教程中用引用的模板是 wap 里的,也就是說你的模板里要有 wap 文件夾,且里面要有相應的模板。當然,你也可以把 wap 改成 content ,不過此時生成移動端頁面是和移動端一樣的,你也可以用這個方法來測試 是否可以生成移動端頁面。

同時,這個方法可以實現雙模板,不知道聰明的你有沒有發現呢?

本次的教程分享到這就結束了,如果你有什么疑問可以在評論區留言,或者發電子郵件提問。






 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 在线2区 | 亚洲国产中文字幕 | 人人玩人人爽 | 欧美69free性videos | 色婷婷久久一区二区 | 毛片视频网站在线观看 | 成人羞羞视频在线观看免费 | 久久久久久亚洲国产精品 | 久久精品中文字幕一区二区三区 | 亚洲欧美日韩精品久久 | 久久久久免费精品国产小说色大师 | av大全在线播放 | 一本一本久久a久久精品综合小说 | 亚洲一区二区三区高清 | 男女一边摸一边做羞羞视频免费 | 黄色羞羞视频在线观看 | 中文字幕欧美在线 | 久久亚洲成人 | 久久华人 | 亚洲99 | 国产精品久久久久久久久久iiiii | 精品国产一区二区三区四区阿崩 | 国产黄色免费网站 | 色av综合在线| 欧美成人高清视频 | 精品亚洲一区二区三区 | 国产精品亚洲欧美 | 特级毛片a级毛片100免费 | 久久亚洲精品国产一区 | 国产一级大片 | 久久99国产精品免费网站 | 日本成人在线免费 | 免费观看黄视频 | 久草视频国产在线 | 欧美日韩手机在线观看 | 欧美成人一级片 | 久久久久久久久久美女 | 性爱视频免费 | 欧美18—19sex性hd | 久久久久亚洲精品国产 | 天天夜夜操操 |