切換模闆
app/config.php下的 CMF設定一到兩個全部數組變量
'cmf_mobile_theme_path' => 'themes/', //(public視情況而定加)
'cmf_mobile_default_theme' => 'simplemobile', //(mobile為手機版檔案名*)
首頁擷取模闆變量
simplewind->cmf->common.php->cmf_get_current_theme
function cmf_get_current_theme()
{
static $_currentTheme;
if (!empty($_currentTheme)) {
return $_currentTheme;
}
$t = 't';
if(cmf_is_mobile()){
$theme = config('cmf_mobile_default_theme');
$cmfDetectTheme = config('cmf_mobile_detect_theme');
$cookie_cmf_template = 'cmf_mobile_template';
$cookie_cmf_design_template = 'cmf_mobile_template';
}else{
$theme = config('cmf_default_theme');
$cmfDetectTheme = config('cmf_detect_theme');
$cookie_cmf_template = 'cmf_template';
$cookie_cmf_design_template='cmf_template';
}
if ($cmfDetectTheme) {
if (isset($_GET[$t])) {
$theme = $_GET[$t];
cookie($cookie_cmf_template, $theme, 864000);
} elseif (cookie($cookie_cmf_template)) {
$theme = cookie($cookie_cmf_template);
}
}
//鈎子插件hook_one('switch_theme');
//對呀plugin表的 name =>SwitchThemeDemo中的config字段JSON
if(cmf_is_mobile()&&empty($theme)){
$hookTheme = hook_one('switch_theme');
if ($hookTheme) {
$theme = $hookTheme;
}
}
$designT='_design_theme';
if (isset($_GET[$designT])) {
$theme = $_GET[$designT];
cookie($cookie_cmf_design_template, $theme, 864000);
} elseif (cookie($cookie_cmf_design_template)) {
$theme = cookie($cookie_cmf_design_template);
}
$_currentTheme = $theme;
return $theme;
}
//轉載https://www.thinkcmf.com/topic/2741.html