1

i want to check the response of the http request on my url on Prestashop, i do something like this but is wrong, i know i don't use the right syntax anyone can help me pls !!

{$url = '$urls.base_urlfiche/$language.language_code/$product.reference_to_display.php';}
      {$headers = @get_headers($url);}
      {if ($headers && strpos($headers[0],'200'))}
      $status = true;
       
      {else} $status = false;{/if}

      {if ($status = true)}
      <a class="attachment-file" href="{$urls.base_url}fiche/{$language.language_code}/{$product.reference_to_display}.php">{l s='Fiche technique' d='Shop.Theme.Catalog'}</a>
      {/if}
    {else}
      {/if}
Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236
Noobs
  • 11
  • 4

1 Answers1

1

you can check the response status of an URL using cURL - There a lot of topic about this (example here)

Anyway it seems like you are mixing up Smarty syntax and PHP here.

If you want to write some PHP code inside a Smarty template (altough discouraged) , you will have to use

{php} your php code here {/php}  

See here

But if you are using this inside a Prestashop module, just write your PHP logic in the PHP file, then assign a smarty variable with status code using $smarty->assign and pass it to the template.

gennaris
  • 1,467
  • 1
  • 11
  • 17