1

I am working on Magento store version 2.1. I'm required to show a different layout and design on the Mobile device, which is different from my default view. For this I added a theme in the root folder of Magento store. I am trying to add this user string -

iPhone|iPod|BlackBerry|Palm|Googlebot-Mobile|Mobile|mobile|mobi|Windows Mobile|Safari Mobile|Android|Opera Mini

I also tried this code -

iPad|iPhone|Android ((?!(2\.|3\.|4\.0)).)

I also added this code in my index.php -

$mobile_agents = "/(nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|"  
                 . "htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|"  
                 . "blackberry|blackberry10|bb10|playbook|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|"  
                 . "symbian|smartphone|mmp|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|"  
                 . "jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220"  
                 . ")/i";  
if (preg_match($mobile_agents, strtolower($_SERVER['HTTP_USER_AGENT']))) {
     $mageRunCode = 'mobile';  // your store view code
}
Mage::run($mageRunCode, $mageRunType);

But nothing is helpful for me.

If anyone knows how to achieve this please write here.

My web URL is - https://www.anytimehydration.com

  • Check out the Design Configuration section of the dev docs step #4. docs.magento.com/m2/2.1/ce/user_guide/design/configuration.html. I've yet to try this feature before but it appears to me that is along the lines of what you're asking for. – Mat Hellums Dec 7 '17 at 5:54
  • Hello Mat thank you for your revert. Stil I am unable to find the actual string what will be placed if I am using theme for android and iphone. Can you help in this please. – R K Shrivastaw Dec 7 '17 at 9:38
0

Are you sure you need a second theme for mobile? do you want to have different templates? Magento 2 is mobile first, you should learn how to theme in magento 2.

http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/responsive-web-design/rwd_css.html

  • Yesh i am very sure about that I need a different theme for mobile. Because I want to display different slider images and different block in mobile. Only footer will be same. – R K Shrivastaw Dec 5 '17 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.