如何在 Prestashop 1.7 的移动设备中显示代码
How to show code in Mobile device in Prestashop 1.7
我需要在 Prestashop 1.7 中添加自定义代码,仅用于移动访问。 Css 显示 none 不是我正在寻找的解决方案。在之前的 PS 1.6 中,有效的代码是 {if $isMobile} 并检查 PS 1.7 文件 classes/Context.php 但包含变量 "isMobile".
我尝试在 .tpl 文件中添加 {if $isMobile} 或 {if $mobile_device} 但它不起作用
在你的控制器模块的getWidgetVariables()
函数中,你可以将下面一行添加到返回的数组中:
'mobile_device' => Context::getContext()->isMobile(),
并查看您的 .tpl:
{if isset($mobile_device) && $mobile_device}
<p>Displayed only on mobile</p>
{/if}
我需要在 Prestashop 1.7 中添加自定义代码,仅用于移动访问。 Css 显示 none 不是我正在寻找的解决方案。在之前的 PS 1.6 中,有效的代码是 {if $isMobile} 并检查 PS 1.7 文件 classes/Context.php 但包含变量 "isMobile".
我尝试在 .tpl 文件中添加 {if $isMobile} 或 {if $mobile_device} 但它不起作用
在你的控制器模块的getWidgetVariables()
函数中,你可以将下面一行添加到返回的数组中:
'mobile_device' => Context::getContext()->isMobile(),
并查看您的 .tpl:
{if isset($mobile_device) && $mobile_device}
<p>Displayed only on mobile</p>
{/if}