C
C
Cinema4d2020-03-10 13:55:31
PHP
Cinema4d, 2020-03-10 13:55:31

Question on smarty and php code how to add?

Hello, tell me, I’m not a programmer guru, but I don’t know smart at all, except that {php} cannot be used with 3.0 and higher, there is a product page that $product.sku comes to and there are two buttons that either send to a page with this product or to an alternative , everything would be fine, this crutch works, but if the partner does not have such a page, then he will transfer it where it is not necessary, so I thought to use something like that

<?php
$url = 'https://yandex.ru';
if(get_headers($url, 1)){
   echo 'Гуд';
}

else 

{
    
    echo 'Нет';
    
}

?>


but in smart such crutches can not be inserted

here is the code that works

{if $product.sku}{*если штрихкод есть то направляем на данный товар на wildberries 2*}
          
              		<div class="btn">
            <a href="https://www.wildberries.ru/catalog/{$product.sku}/detail.aspx?targetUrl=BP"><div class="bye_btn">
              <i class="fa fa-cart-plus" aria-hidden="true"></i>
              <span>Купить в розницу</span>
            </div></a>
          </div>
              
              {else}
              
              <div class="btn">
            <a href="https://www.wildberries.ru/brands/stella"><div class="bye_btn">
              <i class="fa fa-cart-plus" aria-hidden="true"></i>
              <span>Купить в розницу</span>
            </div></a>
          </div>
                    
        {/if}{*wildberries 2*}
              
          {/if}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Gordinskiy, 2020-03-10
@DmitriyGordinskiy

Smarty is a template engine, these crutches have no place in it. Check everything in advance, and pass the result of this check to Smarty.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question