0

I've a list of advanced theme option(checkbox) to not display, such as search bar.

I did many research about custom advanced theme setting, but all the samples are {% if remove_searchbar %}{% endif %}. This render if the option is checked but I want the opposite.

How do I make a statement for if an option is unchecked? I really don't want to do {% if remove_searchbar %}{% else %}{% endif %} or make everything checked by default.

  • 2
    {% if not remove_searchbar %}. See twig.symfony.com/doc/2.x/tags/if.html – leymannx Jul 8 at 17:56
  • @leymannx That works! – CocoSkin Jul 8 at 18:04
  • @leymannx can you put that in answer? – CocoSkin Jul 8 at 18:06
  • 2
    Nah, feel free to do that yourself. 👍 – leymannx Jul 8 at 18:17
  • @CocoSkin, please add the info as answer and mark as resolved. I would add the answer myself but I don't want to steal the karma. – sanzante Jul 20 at 8:38
0

The following answer is credited to @leymannx.

{% if not remove_searchbar %}
  do something
{% endif %}

After some research I found twig syntax. You also can find the "if statement" syntax and samples on Twig Symfony website.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.