I want the following:
& I understand I have to take the codes from context.php of PrestaShop but I seem to be making an error. A link to getcontext is as follows: (The code to detect mobile device is here) 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}
What codes should I enter in the IF condition to make sure it detects mobile and not mobile.
Also is the IF condition written properly, what should I change in this code?
This is.TPL File.
try with:
{if Context::getContext()->isMobile() == 1}
{if Context::getContext()->getDevice() != 2}
// TABLETTE
{else}
// MOBILE
{/if}
{else}
// PC
{/if}
Regards
In Prestashop 1.7.8.2 it works this -->
{assign var="dispositivo" value="desktop"}
{if Context::getContext()->isMobile()}
{assign var="dispositivo" value="mobile"}
{else if Context::getContext()->isTablet()}
{assign var="dispositivo" value="tablet"}
{else}
{assign var="dispositivo" value="desktop"}
{/if}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.