cmf_is_mobile()_ThinkCMF函数

函数介绍:

cmf_is_mobile()

功能:判断是否为手机访问

参数:无

返回:boolean

使用方法:

if(cmf_is_mobile()){
    echo "1";
}else{
    echo "2";
}

实现方式:

例子:响应式网站文章列表页分页数量,PC端显示8条文章,移动端显示4条文章。

文章列表articles标签中有一个page属性,含义是“分页参数,如果设置分页参数会自动分页”;

<portal:articles?..此处省略..?page="10"?..此处省略..?>

注:page属性是开启分页模式,会使limit属性无效。

声明变量$page,设置分页标签以及文章显示数量。

$page=[
    'list_rows'=>'10',
    'next'=>'下一页',
    'prev'=>'上一页'
];

page属性值修改为$page

<portal:articles ..此处省略.. page="$page" ..此处省略.. >

使用函数cmf_is_mobile()

 if(cmf_is_mobile()){
    $page=[
        'list_rows'=>'4',
        'next'=>'>',
        'prev'=>'<'
    ];
}else{
    $page=[
        'list_rows'=>'8',
        'next'=>'下一页',
        'prev'=>'上一页'
    ];
}

Comments 0

0.162015s