Empire CMS: Sending Desktop Visitors to the Mobile Site, Static or Dynamic

Empire CMS mobile redirect code

Empire CMS 7.2 introduced full multi-terminal support, which makes building separate mobile versions far easier. 7.5 took it further: static pages for every terminal can now be regenerated from the main site's admin panel, so running terminals in static mode is much more practical.

1. Page head. Put this HTML right before the body tag

<script type="text/javascript">
try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
{if ((navigator.userAgent.match(/(ipod|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i)))
{window.location="'http://m.aijun.org/'";}}}
catch(err)
{
}</script>
<script data-fixed="true">
  !function(){
    function params(u, p){
      var m = new RegExp("(?:&|/?)"+p+"=([^&$]+)").exec(u);
      return m ? m[1] : '';
    }
    if(/iphone|ios|android|ipod/i.test(navigator.userAgent.toLowerCase()) == true && params(location.search, "from") != "mobile"){
      location.href = 'http://m.aijun.org/';
    }
  }();
</script>

2. List pages

Dynamic: http://m.aijun.org/e/action/ListInfo/?classid=[!--self.classid--]
Static: http://m.aijun.org<?$r['classid']=$GLOBALS[navclassid];$classurl=sys_ReturnBqClassname($r,9);echo $classurl;?>

3. Content pages

Dynamic: http://m.aijun.org/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]
Static: http://m.aijun.org[!--titleurl--]

Both the dynamic and static routes are listed — swap aijun.org for your own subdomain.

Leave a Comment

Comments No Comments

Table of Contents