Answers.Body: <pre><code>{% set class = (currentPage == "search")? '5col' : '3col' %} 
  {% for project in pageEntries %}
       {% include '_partials/search-block' with { 
          extraClasses: class
       } %} 
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-10T17:11:01.580Z
Answers.Text: Nice. You set a var, check for the "search page", implement 5col else use 3col. pass the var to "extraClasses". Thank you @robin
Answers.UserDisplayName: TRIM
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-09T20:26:22.533Z
Answers.LastActivityDate: 2018-05-09T20:26:22.533Z
Answers.UserDisplayName: Robin Schambach
Body: <p>I'm looking for a shorter way of writing this check. If the user visits the search page, apply the 3 column to the search-block, else use the 5 column:</p>
  
  <pre><code>{% set currentPage = 'search' %}
  {% if currentPage == "search" %}
     {% for project in pageEntries %}
        {% include '_partials/search-block' with {
           extraClasses: '3col'                    
           } 
        %}
     {% endfor %}
  {% else %}
     {% for project in pageEntries %}
        {% include '_partials/search-block' with {
           extraClasses: '5col'                    
           } 
        %}
     {% endfor %}
  {% endif %}
  </code></pre>
  
Tags: <conditional>
Title: Check if page is Search, use different classes
ThreadText: # Check if page is Search, use different classes
  
  (Asked by: username_0 on 2018-05-09)
  
  I'm looking for a shorter way of writing this check. If the user visits the search page, apply the 3 column to the search-block, else use the 5 column:
  
  ```
  {% set currentPage = 'search' %}
  {% if currentPage == "search" %}
     {% for project in pageEntries %}
        {% include '_partials/search-block' with {
           extraClasses: '3col'                    
           } 
        %}
     {% endfor %}
  {% else %}
     {% for project in pageEntries %}
        {% include '_partials/search-block' with {
           extraClasses: '5col'                    
           } 
        %}
     {% endfor %}
  {% endif %}
  
  ```
  
  **Tags:** conditional
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-05-09. Score: 1 | Accepted answer
  
  ```
  {% set class = (currentPage == "search")? '5col' : '3col' %} 
  {% for project in pageEntries %}
       {% include '_partials/search-block' with { 
          extraClasses: class
       } %} 
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: Nice. You set a var, check for the "search page", implement 5col else use 3col. pass the var to "extraClasses". Thank you @username_1  
  
  ---
  
  