Answers.Body: <p>Since you've confirmed that the issue is in the <code>if</code> statement and I can see your <em>comparison</em>, I'll clarify usage and propose a solution.</p>
  
  <p>The <code>in</code> operator, is a <a href="http://twig.sensiolabs.org/doc/2.x/templates.html#containment-operator" rel="nofollow noreferrer">containment operator</a> and it expects a <code>scalar|primitive</code> value on the left and an <code>array|iterable</code> on the right.</p>
  
  <p>I am assuming that <code>entry.publishYear</code> is an <code>int</code> or a <code>string</code>: <code>2017</code>. However, I'm not sure about <code>currentEdition.currentYear</code>. It seems like it's also an <code>int</code> or <code>string</code>: <code>2017</code>.</p>
  
  <p>If the <code>currentEdition.currentYear</code> is not an <code>array</code> or an <code>iterable</code> item, you should use <code>==</code> instead of <code>in</code>.</p>
  
  <p><code>{% if entry.publishYear == currentEdition.currentYear %}</code></p>
  
  <p>Have you tried that? Or can you try it and let me know?</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-15T17:28:35.227Z
Answers.Text: I have tried that. meant to use that in my question. I tried "matches" == and some others. "Same as" maybe. all return nothing. The values are all strings. I have not tried them as integers. I could. It would involve my editor inputting the numbers that represent the month and year instead of selecting them with a click of the mouse. A minor thing.
Answers.UserDisplayName: afc
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-15T17:35:39.743Z
Answers.Text: And you've checked that some of the comparisons actually match or should match?
Answers.UserDisplayName: Selvin Ortiz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-15T18:29:32.430Z
Answers.Text: I've check the variables outside the for loop, and inside it, without the if statement and they both return properly. Perhaps there is a space in a variable somewhere.
Answers.UserDisplayName: afc
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-19T15:32:06.657Z
Answers.Text: Got it working with {% if entry.currentYear2 == currentEdition.currentYear2 and currentEdition.currentMonth2 in entry.currentMonth2 %}, but all the variables had to be INT and not String.
Answers.UserDisplayName: afc
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-15T17:18:27.073Z
Answers.LastActivityDate: 2017-03-15T17:18:27.073Z
Answers.UserDisplayName: Selvin Ortiz
Body: <p>There is a <code>publishMonth</code> (multiselect) and <code>publishYear</code> (radio buttons) field in each article. They do not correspond to an actual date. Each article is is associated with one year, or one or more months. I'd like my editor to be able to change two global variables. <code>currentMonth</code> (radio button), and <code>currentYear</code> (radio button) to change all the articles display on the webpage at once at any time she pleases. Some articles may be associated with one or more months. Articles do not get changed over at the same date and time each month, which is why it's not associated with a real month or year. The code below returns nothing.</p>
  
  <p>The idea is to make it as easy as possible for my editor to "flick the switch" to the next month.</p>
  
  <pre><code>{% set dogs = craft.entries.section('news').order('articleOrder desc').limit(5) %}
  {% for entry in dogs %}
  
      {% if entry.publishYear in currentEdition.currentYear %}
  
      &lt;a href="{{ entry.url }}"&gt;&lt;h2&gt;{{ entry.title }}&lt;/h2&gt;&lt;/a&gt;
      {% for image in entry.images.limit(1) %}
          &lt;img src="{{ image.getUrl('frontPageThumbnail') }}" class="main-image"&gt;
      {% endfor %}
      &lt;p&gt;{{ entry.body|striptags|slice(0,300) }}... &lt;a href="{{ entry.URL }}" class="readmore"&gt;Read more&lt;/a&gt;&lt;/p&gt;
      &lt;p&gt;{{ entry.publishYear }}&lt;/p&gt;
      &lt;ul&gt;
          {% for option in entry.publishMonth %}
              &lt;li&gt;{{ option }}&lt;/li&gt;
          {% endfor %}
      &lt;/ul&gt;
  
      {% endif %}
  
  {% endfor %}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-03-15T17:04:58.667Z
Comments.Text: The for loop returns everything as per normal without the if statement I threw in there.
Comments.UserDisplayName: afc
Tags: <forloop><entries-field><globals><comparisons>
Title: I want to display entries that have a field that is the same as a field in a global variable
ThreadText: # I want to display entries that have a field that is the same as a field in a global variable
  
  (Asked by: username_0 on 2017-03-15)
  
  There is a `publishMonth` (multiselect) and `publishYear` (radio buttons) field in each article. They do not correspond to an actual date. Each article is is associated with one year, or one or more months. I'd like my editor to be able to change two global variables. `currentMonth` (radio button), and `currentYear` (radio button) to change all the articles display on the webpage at once at any time she pleases. Some articles may be associated with one or more months. Articles do not get changed over at the same date and time each month, which is why it's not associated with a real month or year. The code below returns nothing.
  
  The idea is to make it as easy as possible for my editor to "flick the switch" to the next month.
  
  ```
  {% set dogs = craft.entries.section('news').order('articleOrder desc').limit(5) %}
  {% for entry in dogs %}
  
      {% if entry.publishYear in currentEdition.currentYear %}
  
      <a href="{{ entry.url }}"><h2>{{ entry.title }}</h2></a>
      {% for image in entry.images.limit(1) %}
          <img src="{{ image.getUrl('frontPageThumbnail') }}" class="main-image">
      {% endfor %}
      <p>{{ entry.body|striptags|slice(0,300) }}... <a href="{{ entry.URL }}" class="readmore">Read more</a></p>
      <p>{{ entry.publishYear }}</p>
      <ul>
          {% for option in entry.publishMonth %}
              <li>{{ option }}</li>
          {% endfor %}
      </ul>
  
      {% endif %}
  
  {% endfor %}
  
  ```
  
  **Tags:** forloop, entries-field, globals, comparisons
  
  > **Comments:**
  > **username_0**: The for loop returns everything as per normal without the if statement I threw in there.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-03-15. Score: 1
  
  Since you've confirmed that the issue is in the `if` statement and I can see your *comparison*, I'll clarify usage and propose a solution.
  
  The `in` operator, is a [containment operator](http://twig.sensiolabs.org/doc/2.x/templates.html#containment-operator) and it expects a `scalar|primitive` value on the left and an `array|iterable` on the right.
  
  I am assuming that `entry.publishYear` is an `int` or a `string`: `2017`. However, I'm not sure about `currentEdition.currentYear`. It seems like it's also an `int` or `string`: `2017`.
  
  If the `currentEdition.currentYear` is not an `array` or an `iterable` item, you should use `==` instead of `in`.
  
  `{% if entry.publishYear == currentEdition.currentYear %}`
  
  Have you tried that? Or can you try it and let me know?
  
  > **Comments:**
  > **username_0**: I have tried that. meant to use that in my question. I tried "matches" == and some others. "Same as" maybe. all return nothing. The values are all strings. I have not tried them as integers. I could. It would involve my editor inputting the numbers that represent the month and year instead of selecting them with a click of the mouse. A minor thing.  
  > **username_1**: And you've checked that some of the comparisons actually match or should match?  
  > **username_0**: I've check the variables outside the for loop, and inside it, without the if statement and they both return properly. Perhaps there is a space in a variable somewhere.  
  > **username_0**: Got it working with {% if entry.currentYear2 == currentEdition.currentYear2 and currentEdition.currentMonth2 in entry.currentMonth2 %}, but all the variables had to be INT and not String.  
  
  ---
  
  