thinkcmf 5.0.190111 , 手机端 AND 电脑端 分别调用不同的模板
2019年5月21日1.编辑\app\config.php
的配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
. . 此处省略代码 . // +---------------------------------------------------------------------- // | CMF模板 设置 // +---------------------------------------------------------------------- 'cmf_theme_path' => 'themes/', 'cmf_default_theme' => 'simpleboot3', 'cmf_admin_theme_path' => 'themes/', 'cmf_admin_default_theme' => 'admin_simpleboot3', 'cmf_mobile_theme_path' => 'themes/', #需要添加的配置 'cmf_mobile_default_theme' => 'mobile', #需要添加的配置 . . 此处省略代码 . |
2.编辑simplewind/cmf/common.php
文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
. . 此处省略代码 . function cmf_get_current_theme() { static $_currentTheme; if (!empty($_currentTheme)) { return $_currentTheme; } $t = 't'; //判断是否是手机访问,需要添加的判断 if(cmf_is_mobile()){ $theme = config('template.cmf_mobile_default_theme'); }else{ $theme = config('template.cmf_default_theme'); } $cmfDetectTheme = config('template.cmf_detect_theme'); if ($cmfDetectTheme) { if (isset($_GET[$t])) { $theme = $_GET[$t]; cookie('cmf_template', $theme, 864000); } elseif (cookie('cmf_template')) { $theme = cookie('cmf_template'); } } $hookTheme = hook_one('switch_theme'); if ($hookTheme) { $theme = $hookTheme; } $designT = '_design_theme'; if (isset($_GET[$designT])) { $theme = $_GET[$designT]; cookie('cmf_design_theme', $theme, 4); } elseif (cookie('cmf_design_theme')) { $theme = cookie('cmf_design_theme'); } $_currentTheme = $theme; return $theme; } . . 此处省略代码 . |