Jump to content

Context.php getMobileDevice() not working in PS 1.6.1.10


AgustinCecotec

Recommended Posts

Hi, recently I needed to use the Mobile_Detect php library inside prestashop to add a custom code when my webpage is shown in a mobile/tablet device.

 

Searching through PS Front Controller i saw how many values are given to smarty, between them is 'mobile_device' who calls the function getMobileDevice inside Context.php. Well...when it's used as a variable in a .tpl folder like {$mobile_device} it prints nothing (and it must print a boolean).

 

Finally I ended doing an override of the Front Controller and adding a new assignment to smarty which calls to getDevice function (inside Context.php too). This is working well, but I don't understand what's wrong with getMobileDevice code.

 

If this is a general issue, maybe it can be solved in the next updates.

 

See ya!

Link to comment
Share on other sites

sometimes boolean false is returned as null/empty.  so when that happens, you can use the isset function to check if it is both 'set' and 'true', otherwise it is false.

 

now if your question is... why does it not detect your mobile device, you will need to debug that code and confirm your mobile device is actually being detected

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...