我想要以下内容:
& 我知道我必须从 PrestaShop 的 context.php 中获取代码,但我似乎犯了一个错误。 getcontext的链接如下:(检测移动设备的代码在这里) https://github.com/PrestaShop/PrestaShop/blob/develop/classes/Context.php
{if isset($products) AND $products}
{$tabname=rand()+count($products)}
{if isset($display_mode) && $display_mode == 'carousel'}
{include file="{$items_owl_carousel_tpl}" items=$products image_size=$image_size}
{else}
{if device is MOBILE} /* Correct Code Needed */
{include file="{$items_normal_tpl}" items=$products image_size="homepage_default"}
{else device is NOT MOBILE} /* Correct Code Needed */
{include file="{$items_normal_tpl}" items=$products image_size="home_default"}
{/if}
{/if}
{/if}
我应该在 IF 条件中输入什么代码以确保它检测到移动设备而不是移动设备。
另外IF条件写的对不对,这段代码要改什么?
这是 .TPL 文件。
最佳答案
尝试:
{if Context::getContext()->isMobile() == 1}
{if Context::getContext()->getDevice() != 2}
// TABLETTE
{else}
// MOBILE
{/if}
{else}
// PC
{/if}
问候
关于php - 如何在 TPL 文件中的 prestashop 1.7 中检测 smarty 中的设备?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56275172/