Question

my opencart theme not responsive anymore, i had created a new theme that mobile friendly located on catalog/view/theme/mobile/.... so now my store theme folder have following 2 themes

catalog/view/theme/desktop
catalog/view/theme/mobile

i know how to detect mobile device then redirect to specific domain address. but that not possible here, if i do this steps must create a new store like m.mystore.com

following code i use in catalog/view/theme/desktop/template/common.header.tpl for detect mobile device then redirect to mobile sotre

 <script type="text/javascript">// <![CDATA[
    var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
    if (mobile) {
        document.location = "http://m.mytore.com";
    }
// ]]></script>

above method not suitable for my needs

so my question is how can i redirect template folder to catalog/view/theme/mobile if detect mobile device except create new store.?

thanks for any help

Was it helpful?

Solution

put the php code for mobile detection in the config.php file. Then, if mobile detected, you use a different definition for the themes directory.

if($ismobile){
define('DIR_TEMPLATE', 'C:\wamp\www\opencart/catalog/view/themeMobile/');
}else{
define('DIR_TEMPLATE', '/var/www/pharmalife365.com/catalog/view/themeMobile/');
}

As long as your theme has the same name on both folders, this should work :D

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top