Get Free Audit

How Prestashop will work with mobile themes… Probably will.

Jun 20, 2012

1042 Alex Simonchik

How Prestashop will work with mobile themes… Probably will.

It’s said “probably” because unlike 1.5.0.9 Prestashop version, the latest 1.5.0.13 version (released on June, 7) has no methods for mobile device detection. Changelog in version 1.5.0.13 says nothing about it while Changelog in version 1.5.0.9 reports:

Improved/changed features:
[*] FO : Add mobile detection and mobile theme dispatcher

Where does the truth lie? We, folks, are confused. Anyways, I really hope that a mobile theme is not ready yet and developers will be given a nice present with a final version release.

So let’s see how methods worked in Prestashop 1.5.0.9.

A new config/defines_uri.inc.php file has appeared with the following code:

This code above suggests that the theme should be available on FTP at «_PS_THEME_DIR_.’mobile/’» or «_PS_ROOT_DIR_.’/themes/default/mobile/» addresses to work properly. In addition, «img/», «css/», «js/» directories are provided for mobile themes.

Context::getMobileDevice() function is in charge of mobile device identification.

The identification of whether this device is mobile will be conducted after comparing «HTTP_USER_AGENT» with a predefined pattern that contains header parts of the majority of mobile devices.

Let’s see where «getMobileDevice» function is used:

grep -rH “getMobileDevice” ./classes
./classes/controller/FrontController.php:                       ‘mobile_device’ => $this->context->getMobileDevice(),
./classes/controller/FrontController.php:               if ($this->context->getMobileDevice() != false)
./classes/controller/FrontController.php:               if ($this->context->getMobileDevice() != false)
./classes/controller/FrontController.php:               if ($this->context->getMobileDevice() != false)
./classes/controller/FrontController.php:               if ($this->context->getMobileDevice() == false)
./classes/controller/FrontController.php:               if ($this->context->getMobileDevice() == false && Tools::isSubmit(‘live_edit’))
./classes/controller/FrontController.php:               if ($this->context->getMobileDevice() != false || file_exists(_PS_THEME_DIR_.’layout.tpl’))
./classes/controller/FrontController.php:                       $template_dir = ($this->context->getMobileDevice() == true ? _PS_THEME_MOBILE_DIR_ : _PS_THEME_DIR_);
./classes/controller/FrontController.php:               if ($this->context->getMobileDevice() != false)
./classes/controller/FrontController.php:               if ($this->context->getMobileDevice() != false)
./classes/Context.php:  public function getMobileDevice()

This function is mainly used in classes/controller/FrontController.php:

Vlad Yunusov
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Vlad



Context:: getTouchPadDevice() function may also seem pretty interesting:

This function returns the type of the touchpad device. We can expect that Prestashop will probably distinguish mobile devices form touchpad ones.

Unfortunately, I haven’t found where this function is used. Perhaps, it will be applied somehow in the future.

Vlad Yunusov
Partner With Us Looking for a partner that will help you to grow your business? We are the right company to develop your webstore. Feel free to get in touch with us. We will be happy to discuss your business opportunities and provide you with a Free Quote. Talk to Vlad

2 Comments

  1. Hi Alex,

    you can activate the mobile-theme by adding ‘PS_ALLOW_MOBILE_DEVICE’ = 1 to the configuration table. Make sure you got the template-files: /theme/default/mobile/

    .. or patch the getMobileDevice()-function on line 118 (/classes/Context.php) change:
    return $this->mobile_device; to return ‘iphone’;

    regards,
    Pegen

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *