D
D
De-122020-08-11 09:44:59
PHP
De-12, 2020-08-11 09:44:59

How to convert PHP code to TWIG?

Greetings, there is a code to check for a user agent to hide the metric from page-speed, it does not work on opencart 3, because there is a TWIG code, I tried it through the PHP to TWIG conventions - the site crashes, can anyone help with this issue? Code below.

<?php if (!isset($_SERVER['HTTP_USER_AGENT']) || stripos($_SERVER['HTTP_USER_AGENT'], 'Lighthouse') === false): ?>
<?php endif; ?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IvanMogilev, 2020-08-11
@De-12

in controller

if (!isset($_SERVER['HTTP_USER_AGENT']) || stripos($_SERVER['HTTP_USER_AGENT'], 'Lighthouse') === false)
        {
            $data['check']=true;
        }
        else
        {
            $data['check']=false;
        }

in twig
{% if check == true %}
    скрипты
{% endif %}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question