3

Hi so I have this php code:

<p style="text-align: center;">Showing urns for a <?php echo $person_or_animal; if( $ashes_size=='small' ){ echo ' that holds a small amount of ashes.'; }else{ echo ' '.$pp_weight; ?> cubic inches and larger. <?php } ?> <a href="<?php echo $home_url; ?>">Start over?</a></p>

which I converted to twig like this:

<p style="text-align: center;">Showing urns for a {{ person_or_animal }} {% if ashes_size is 'small' %} {{ ' that holds a small amount of ashes.' }} {% endif %}{% else %}  {{ ' '~pp_weight }} cubic inches and larger. <a href="<?php echo $home_url; ?>">Start over?</a></p>

But when I access the page I get this:

Fatal error: 'Unexpected token "string" of value "small" ("name" expected) in "default/template/extension/module/urnfindersearch.twig" at line 12.'

any idea the reason why this could be happening? as I am not a twig expert so if someone could help me that would be great.

Thanks Aaron

Marios
  • 26,333
  • 8
  • 32
  • 52
  • `{% if ashes_size === 'small' %}` ?? – A. Meshu Aug 15 '20 at 22:07
  • Thanks for that :), it did help me get that section working in right direction it was == but problem i have now is: `{% if ( in_array(id, cats) ) %} {{ 'checked' }}{% endif %}` i get: Fatal error: 'Unknown "in_array" function in "default/template/extension/module/urnfindersearch.twig" at line 22.' the php for this line is: `` – AARON HEALEY Aug 15 '20 at 23:14
  • Please start with reading the [documentation](https://twig.symfony.com/doc/3.x/templates.html). It's all in there – DarkBee Aug 16 '20 at 08:11
  • Thanks for your posts :) i managed to solve it by doing: {% if id in cats %} :). – AARON HEALEY Aug 17 '20 at 00:28

0 Answers0