Answers.Body: <p>Yes that's possible, all Twig loops have a <a href="http://twig.sensiolabs.org/doc/tags/for.html#the-loop-variable" rel="noreferrer"><code>loop</code> variable</a>:</p>
  
  <blockquote>
    <p><code>loop.index</code> - The current iteration of the loop. (1 indexed)<br>
    <code>loop.index0</code> - The current iteration of the loop. (0 indexed)</p>
  </blockquote>
  
  <p><strong>Example:</strong></p>
  
  <pre class="lang-twig prettyprint-override"><code>{% for block in entry.myMatrixField %}
    {% if block.type == "quote" %}
      &lt;blockquote class="quote{{ loop.index }}"&gt;
        &lt;p&gt;{{ block.quote }}&lt;/p&gt;
      &lt;/blockquote&gt;
    {% endif %}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-13T11:39:41.070Z
Answers.LastActivityDate: 2014-08-13T11:39:41.070Z
Answers.UserDisplayName: Victor
Body: <p>Just wondering if there's a way to return the matrix block number during the loop?</p>
  
  <p>For example:</p>
  
  <pre><code>{% for block in entry.myMatrixField %}
    {% if block.type == "quote" %}
      &lt;blockquote class="quote{{GET_BLOCK_NUMBER}}"&gt;
        &lt;p&gt;{{ block.quote }}&lt;/p&gt;
      &lt;/blockquote&gt;
    {% endif %}
  {% endfor %}
  </code></pre>
  
  <p>Might return something like this:</p>
  
  <pre><code>&lt;blockquote class="quote1"&gt;
    &lt;p&gt;Curabitur aliquet quam id dui posuere blandit.&lt;/p&gt;
  &lt;/blockquote&gt;
  &lt;blockquote class="quote2"&gt;
    &lt;p&gt;Curabitur aliquet quam id dui posuere blandit.&lt;/p&gt;
  &lt;/blockquote&gt;
  &lt;blockquote class="quote3"&gt;
    &lt;p&gt;Curabitur aliquet quam id dui posuere blandit.&lt;/p&gt;
  &lt;/blockquote&gt;
  </code></pre>
  
  <p>Thanks, Mark</p>
  
Tags: <matrix>
Title: Return Matrix Field block number
ThreadText: # Return Matrix Field block number
  
  (Asked by: username_0 on 2014-08-13)
  
  Just wondering if there's a way to return the matrix block number during the loop?
  
  For example:
  
  ```
  {% for block in entry.myMatrixField %}
    {% if block.type == "quote" %}
      <blockquote class="quote{{GET_BLOCK_NUMBER}}">
        <p>{{ block.quote }}</p>
      </blockquote>
    {% endif %}
  {% endfor %}
  
  ```
  
  Might return something like this:
  
  ```
  <blockquote class="quote1">
    <p>Curabitur aliquet quam id dui posuere blandit.</p>
  </blockquote>
  <blockquote class="quote2">
    <p>Curabitur aliquet quam id dui posuere blandit.</p>
  </blockquote>
  <blockquote class="quote3">
    <p>Curabitur aliquet quam id dui posuere blandit.</p>
  </blockquote>
  
  ```
  
  Thanks, Mark
  
  **Tags:** matrix
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-08-13. Score: 8 | Accepted answer
  
  Yes that's possible, all Twig loops have a [`loop` variable](http://twig.sensiolabs.org/doc/tags/for.html#the-loop-variable):
  
  > `loop.index` - The current iteration of the loop. (1 indexed)  
  > `loop.index0` - The current iteration of the loop. (0 indexed)
  
  **Example:**
  
  ```twig
  {% for block in entry.myMatrixField %}
    {% if block.type == "quote" %}
      <blockquote class="quote{{ loop.index }}">
        <p>{{ block.quote }}</p>
      </blockquote>
    {% endif %}
  {% endfor %}
  
  ```
  
  
  ---
  
  