Answers.Body: <p>Your issue is probably that you're actually comparing an <a href="https://craftcms.com/docs/templating/entrymodel" rel="nofollow noreferrer">EntryModel</a> (<code>entry</code>) to an <a href="https://craftcms.com/docs/templating/elementcriteriamodel" rel="nofollow noreferrer">ElementCriteriaModel</a> (the array-like object used for querying entries, which is returned by the <code>craft.entries</code> call).</p>
  
  <p>Something like this should do it:</p>
  
  <pre><code>{% if entry.section.handle == 'homepage' %}
      {{ entry.hero }}
  {% elseif entry.section.handle == 'smallgroups' %}
      Groups
  {% else %}
      {{ entry.title }}
  {% endif %}
  </code></pre>
  
  <p>Assuming your section handles are correct, the above should work – although this is a perfect use for using the <a href="https://craftcms.com/docs/templating/switch" rel="nofollow noreferrer"><code>{% switch %}</code></a> tag instead of <code>{% if %}</code>, which in my opinion would make your code more readable:</p>
  
  <pre><code>{% switch entry.section.handle %}
      {% case 'homepage' %}
          {{ entry.hero }}
      {% case 'smallgroups' %}
          Groups
      {% default %}
          {{ entry.title }}
  {% endswitch %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-29T22:30:06.123Z
Answers.Text: `{% switch %}` worked perfectly. I thought those only worked with matrix fields. Thanks for clarifying.
Answers.UserDisplayName: Jeff Fulton
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-29T23:33:48.377Z
Answers.Text: @JeffFulton Nah, it's just a variation on the if/else statement. You can always get by with the latter, but code-wise it's often more concise when your conditional is based around multiple possible values for a single variable. To be clear, the use of if/else wasn't the reason your original code didn't work; it was the fact that you were comparing an EntryModel to an ElementCriteriaModel.
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-29T06:39:43.540Z
Answers.LastActivityDate: 2017-09-29T06:39:43.540Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <p>I have a hero textbox that I would like to control from the base template using a simple if/elseif.</p>
  
  <p>I have a field called "hero" for the homepage. For pages in the "Small Groups" section, I want the hero to say "Groups." For everything else, I want it to be the entry title.</p>
  
  <p>It seems straightforward, but this isn't working? It is ignoring the elseif.</p>
  
  <pre><code>{% if entry == craft.entries.section('homepage') %}
      {{ entry.hero }}
  {% elseif entry == craft.entries.section('smallgroups') %}
      Groups
  {% else %}
      {{ entry.title }}
  {% endif %}
  </code></pre>
  
Tags: <templating>
Title: if / elseif from base template
ThreadText: # if / elseif from base template
  
  (Asked by: username_0 on 2017-09-29)
  
  I have a hero textbox that I would like to control from the base template using a simple if/elseif.
  
  I have a field called "hero" for the homepage. For pages in the "Small Groups" section, I want the hero to say "Groups." For everything else, I want it to be the entry title.
  
  It seems straightforward, but this isn't working? It is ignoring the elseif.
  
  ```
  {% if entry == craft.entries.section('homepage') %}
      {{ entry.hero }}
  {% elseif entry == craft.entries.section('smallgroups') %}
      Groups
  {% else %}
      {{ entry.title }}
  {% endif %}
  
  ```
  
  **Tags:** templating
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-09-29. Score: 2 | Accepted answer
  
  Your issue is probably that you're actually comparing an [EntryModel](https://craftcms.com/docs/templating/entrymodel) (`entry`) to an [ElementCriteriaModel](https://craftcms.com/docs/templating/elementcriteriamodel) (the array-like object used for querying entries, which is returned by the `craft.entries` call).
  
  Something like this should do it:
  
  ```
  {% if entry.section.handle == 'homepage' %}
      {{ entry.hero }}
  {% elseif entry.section.handle == 'smallgroups' %}
      Groups
  {% else %}
      {{ entry.title }}
  {% endif %}
  
  ```
  
  Assuming your section handles are correct, the above should work – although this is a perfect use for using the [`{% switch %}`](https://craftcms.com/docs/templating/switch) tag instead of `{% if %}`, which in my opinion would make your code more readable:
  
  ```
  {% switch entry.section.handle %}
      {% case 'homepage' %}
          {{ entry.hero }}
      {% case 'smallgroups' %}
          Groups
      {% default %}
          {{ entry.title }}
  {% endswitch %}
  
  ```
  
  > **Comments:**
  > **username_0**: `{% switch %}` worked perfectly. I thought those only worked with matrix fields. Thanks for clarifying.  
  > **username_1**: @username_0 Nah, it's just a variation on the if/else statement. You can always get by with the latter, but code-wise it's often more concise when your conditional is based around multiple possible values for a single variable. To be clear, the use of if/else wasn't the reason your original code didn't work; it was the fact that you were comparing an EntryModel to an ElementCriteriaModel.  
  
  ---
  
  