PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, October 27, 2022

[FIXED] How to show code in Mobile device in Prestashop 1.7

 October 27, 2022     prestashop-1.7     No comments   

Issue

I need add a custom code in Prestashop 1.7 only for Mobile visits. Css display none is not the solution I am looking for. In previous PS 1.6 the code what works was {if $isMobile} and checking PS 1.7 file classes/Context.php yet is included the variable "isMobile".

I tried add a {if $isMobile} or {if $mobile_device} in .tpl files but it is not working


Solution

Into the getWidgetVariables() function of your controller module, you can add the following line into array returned:

'mobile_device' => Context::getContext()->isMobile(),

And check into your .tpl:

{if isset($mobile_device) && $mobile_device}
 <p>Displayed only on mobile</p> 
{/if}


Answered By - Klemart3D
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing