首页、分类页、用户页、日期页和标签页都是用的index.php模板页面,如想个性化设置每个页面的模板,可以这样判断
{if $type=='index'&&$page=='1'} <!--/*判断首页*/--> {template:c_list_index} {elseif $type=='category'} <!--/*判断分类页*/--> {template:c_list_cate} {elseif $type=='author'} <!--/*判断用户页*/--> {template:c_list_author} {elseif $type=='date'} <!--/*判断日期页*/ --> {template:c_list_date} {elseif $type=='tag'} <!--/*判断标签页*/--> {template:c_list_tag} {else} <!--/*其他自定义列表页面*/--> {template:c_list} {/if}
判断内容页或者单页
{if $article.Type==0} <!--/*判断文章内页*/--> {template:post-single} {else} <!--/*判断单页*/--> {template:post-page} {/if}
判断当前页面类型
{if $type=='article'} {elseif $type=='page'} {elseif $type=='category'} {elseif $type=='index'} {/if}
判断管理员登录展示内容,否则跳转到登录页面
{if $user.Level==1} {else} {Redirect('/zb_system/login.php')} {/if}
不同分类,展示不同内容
{if $article.Category.ID=='1'} {elseif $article.Category.ID=='2'} {elseif $article.Category.ID=='3'} {/if}
临时,PHP方法,非ZBLOG官方
function is_mobile_device() { $user_agent = $_SERVER['HTTP_USER_AGENT']; return preg_match("/(Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini)/i", $user_agent); } if (is_mobile_device()) { echo "是手机端"; } else { echo "是PC端"; }