Answers.Body: <p>You could query for your two blocks individually.</p>
  
  <pre><code>{% set quoteBlock = entry.intro.type('quote').first() %}
  {% set textBlock = entry.intro.type('text').order('RAND()').first() %}
  
  &lt;blockquote&gt;
      &lt;p&gt;{{ quoteBlock.quote|raw }}&lt;/p&gt;
      &lt;footer&gt;{{ quoteBlock.caption }} &lt;/footer&gt;
  &lt;/blockquote&gt;
  
  &lt;div&gt;{{ textBlock.column1 }}&lt;/div&gt;
  &lt;div&gt;{{ textBlock.column2 }}&lt;/div&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-30T08:44:42.137Z
Answers.LastActivityDate: 2015-10-30T08:44:42.137Z
Answers.UserDisplayName: carlcs
Body: <p>I have a Matrix block with 2 types: quotes and text. The first block contains a quote and a text. The second and following ones only contain quotes.</p>
  
  <p>I want the type text to be limited to 1 and the type quotes limited to one at a time displayed randomly.
  Can't figure out how?</p>
  
  <pre><code>{% for block in entry.intro %}
  
      {% if block.type == "quote" %}
          &lt;div class="col-md-4"&gt;
              &lt;blockquote&gt;
                  &lt;p&gt;{{ block.quote|raw }}&lt;/p&gt;
                  &lt;footer&gt;{{ block.caption }} &lt;/footer&gt;
              &lt;/blockquote&gt;
          &lt;/div&gt;
      {% elseif block.type =="text" %}
          &lt;div class="col-md-4 col-sm-6 mb-sm-50 mb-xs-30"&gt;{{ block.column1 }}&lt;/div&gt;
          &lt;div class="col-md-4 col-sm-6 mb-sm-50 mb-xs-30"&gt;{{ block.column2 }}&lt;/div&gt;
      {% endif %}
  
  {% endfor %}
  </code></pre>
  
Tags: <matrix><loop><random>
Title: Random quotes in matrix block type
ThreadText: # Random quotes in matrix block type
  
  (Asked by: username_0 on 2015-10-29)
  
  I have a Matrix block with 2 types: quotes and text. The first block contains a quote and a text. The second and following ones only contain quotes.
  
  I want the type text to be limited to 1 and the type quotes limited to one at a time displayed randomly.
  Can't figure out how?
  
  ```
  {% for block in entry.intro %}
  
      {% if block.type == "quote" %}
          <div class="col-md-4">
              <blockquote>
                  <p>{{ block.quote|raw }}</p>
                  <footer>{{ block.caption }} </footer>
              </blockquote>
          </div>
      {% elseif block.type =="text" %}
          <div class="col-md-4 col-sm-6 mb-sm-50 mb-xs-30">{{ block.column1 }}</div>
          <div class="col-md-4 col-sm-6 mb-sm-50 mb-xs-30">{{ block.column2 }}</div>
      {% endif %}
  
  {% endfor %}
  
  ```
  
  **Tags:** matrix, loop, random
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-10-30. Score: 1 | Accepted answer
  
  You could query for your two blocks individually.
  
  ```
  {% set quoteBlock = entry.intro.type('quote').first() %}
  {% set textBlock = entry.intro.type('text').order('RAND()').first() %}
  
  <blockquote>
      <p>{{ quoteBlock.quote|raw }}</p>
      <footer>{{ quoteBlock.caption }} </footer>
  </blockquote>
  
  <div>{{ textBlock.column1 }}</div>
  <div>{{ textBlock.column2 }}</div>
  
  ```
  
  
  ---
  
  