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

2
  • 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. Dec 7, 2017 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. Dec 7, 2017 at 9:38

2 Answers 2

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

1
  • 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. Dec 5, 2017 at 13:27
0

You can do it by defining user agent rules under Design Configuration.

Content -> Design -> Configuration

Click on edit button of respective website theme setting and add new user agent rule.

Design Rule -> User Agent Rules -> Add New User Agent Rule

Refer to this for more information and this for M2.1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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