Multiple condition in template

I have a complex operator trying to archive this below multiple condition in template.

  if ( $permission == $authorization || $permission =="Top_Secret" || $permission =="Confidential" || $permission =="Secret" || $permission =="Restricted") {

     } elseif ($permission !="Top_Secret" && $permission =="Confidential" || $permission =="Secret" || $permission =="Restricted") {
     	# code...
     } elseif ($permission !="Top_Secret" || $permission !="Confidential" && $permission =="Secret" || $permission =="Restricted") {
     	# code...
     } elseif ($permission !="Top_Secret" || $permission =="Confidential" || $permission =="Secret" && $permission =="Restricted") {
     	# code...
     } else {
     	# code...

any guide about how to make Multiple condition in


I review this topic Evaluating conditions within Template7

it help me in many cases but I did not find any Multi condition like above. please give me an example how to make this work.

I have try this but not work:

{{#each category.catdata}}
 {{#if @root.category.permission "==" authorization "||" @root.category.permission "==" "Top_Secret" "||" @root.category.permissionon "==" "Confidential" "||" @root.category.permission "==" "Secret" "||" @root.category.permission "==" "Restricted"}}

Instead of the #if operator (which only checks simple conditions), you could use the #js_if operator for extented conditions like this:

  {{#js_if "validPage && (!loginRequired || loggedIn)"}}
    Your content
    Content unavailable

Thank for your reply but how can I achieve this
{{#js_if @root.category.permission "==" authorization "||" @root.category.permission "==" "Top_Secret" }}
using “js_if”.

Not sure about @root, but the overall syntax should be something like this:

{{#js_if "[email protected] == 'authorization' || [email protected] == 'top_secret'"}}
  Content to show
  1. Template scope inside js_if should be prefixed with: this.
  2. You can’t use double quotes, or should escape them properly. But most of the time, single quotes are easier.
1 Like

Thank you your guidance, working perfectly.

This is the final code:

{{#js_if "@root.category.permission == this.authorization || [email protected] == 'Top_Secret' || @root.category.permissionon == 'Confidential' || @root.category.permissionon == 'Secret' || @root.category.permissionon == 'Restricted'"}}

can I use else if for more nested conditions ? answer is Yes, its working like this.

{{#js_if  conditions}}
{{#else_if  conditions}}

Nice! Besides, are you sure #else_if works? That would be great, as I thought it still was a future request on Github. @nolimits4web ?

1 Like

Yes, I already apply on my current project using above nested conditions.

1 Like

i use that to work with multiples conditions, hope help you

<div class="col-25">
{{#js_if "this.tipo === 'catalogo'"}}
    <span class="Montserrat-Bold">Duzani</span>
    {{#js_if "this.tipo === 'catalogoClothingDuzani'"}}
        <span class="Montserrat-Bold">Clothing</span>
        <span class="Montserrat-Bold">Lageli</span>
1 Like