国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 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 ,不過此時生成移動端頁面是和移動端一樣的,你也可以用這個方法來測試 是否可以生成移動端頁面。

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

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






 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 平山县| 台北市| 东乡族自治县| 巨鹿县| 彩票| 怀安县| 苍溪县| 武冈市| 石门县| 措勤县| 内丘县| 富源县| 汉中市| 明溪县| 顺昌县| 商城县| 武川县| 图片| 宜川县| 文昌市| 纳雍县| 泸州市| 安化县| 宾川县| 孟津县| 广河县| 轮台县| 巴里| 东安县| 开阳县| 永平县| 顺义区| 额济纳旗| 金门县| 汝州市| 聂拉木县| 梁平县| 夏河县| 沅陵县| 河北区| 清镇市|