Answers.Body: <p>Since you have 3 block types in your Matrix, you need to check for the block type before trying to call an inner field. </p>
  
  <pre><code>{% block content %}
      &lt;article&gt;
          &lt;h1&gt;{{ entry.title }}&lt;/h1&gt;
          &lt;p&gt;TEST EDIT 8&lt;/p&gt;
          {% for block in entry.blogPost %}
              {% if block.type == 'imageCaption' %}
                  &lt;p&gt;heading - {{ block.heading }}&lt;/p&gt;
                  &lt;p&gt;sub heading - {{ block.subHeading }}&lt;/p&gt;
              {% elseif block.type == 'WhateverTypeAccoladeIsIn' %}
                  &lt;p&gt;accolade- {{ block.accolade }}&lt;/p&gt;
              {% endif %}
          {% endfor %}
  
          &lt;p&gt;Posted on {{ entry.postDate.format('F d, Y') }}&lt;/p&gt;
          {{ entry.body }}
      &lt;/article&gt;
  {% endblock %}
  </code></pre>
  
  <p>You should add that check before <code>block.accolade</code> as well for whichever block type accolade is in.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-24T21:27:59.837Z
Answers.LastActivityDate: 2015-06-24T21:27:59.837Z
Answers.UserDisplayName: Aaron Berkowitz
Body: <p>Here's my code block:</p>
  
  <pre><code>{% extends "_layout" %}
  
  {% block content %}
      &lt;article&gt;
          &lt;h1&gt;{{ entry.title }}&lt;/h1&gt;
          &lt;p&gt;TEST EDIT 8&lt;/p&gt;
          {% for block in entry.blogPost %}
              &lt;p&gt;heading - {{ block.heading }}&lt;/p&gt;
              &lt;p&gt;sub heading - {{ block.subHeading }}&lt;/p&gt;
              &lt;p&gt;accolade- {{ block.accolade }}&lt;/p&gt;
          {% endfor %}
  
          &lt;p&gt;Posted on {{ entry.postDate.format('F d, Y') }}&lt;/p&gt;
          {{ entry.body }}
      &lt;/article&gt;
  {% endblock %}
  </code></pre>
  
  <p><img src="https://i.sstatic.net/iZ3vj.png" alt="enter image description here"></p>
  
  <p>And here's the error message I am getting on an inconsistent basis:</p>
  
  <blockquote>
    <p>Craft\MatrixBlockModel and its behaviors do not have a method or closure named "heading"</p>
  </blockquote>
  
  <p>I've tried to remove the other Matrix fields from the template, and just isolate on the 'block.heading' field, and I get really strange behaviors. Sometimes the template renders fine, and the dynamic value gets rendered by the page. Sometimes, with a different content entry, the same template gives the above error message.</p>
  
  <p>I'm brand new to CraftCMS. Is there an obvious syntax mistake I'm making?</p>
  
Tags: <matrix>
Title: confused by inconsistent behavior of matrix
ThreadText: # confused by inconsistent behavior of matrix
  
  (Asked by: username_0 on 2015-06-24)
  
  Here's my code block:
  
  ```
  {% extends "_layout" %}
  
  {% block content %}
      <article>
          <h1>{{ entry.title }}</h1>
          <p>TEST EDIT 8</p>
          {% for block in entry.blogPost %}
              <p>heading - {{ block.heading }}</p>
              <p>sub heading - {{ block.subHeading }}</p>
              <p>accolade- {{ block.accolade }}</p>
          {% endfor %}
  
          <p>Posted on {{ entry.postDate.format('F d, Y') }}</p>
          {{ entry.body }}
      </article>
  {% endblock %}
  
  ```
  
  ![enter image description here](https://i.sstatic.net/iZ3vj.png)
  
  And here's the error message I am getting on an inconsistent basis:
  
  > Craft\MatrixBlockModel and its behaviors do not have a method or closure named "heading"
  
  I've tried to remove the other Matrix fields from the template, and just isolate on the 'block.heading' field, and I get really strange behaviors. Sometimes the template renders fine, and the dynamic value gets rendered by the page. Sometimes, with a different content entry, the same template gives the above error message.
  
  I'm brand new to CraftCMS. Is there an obvious syntax mistake I'm making?
  
  **Tags:** matrix
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-06-24. Score: 5 | Accepted answer
  
  Since you have 3 block types in your Matrix, you need to check for the block type before trying to call an inner field.
  
  ```
  {% block content %}
      <article>
          <h1>{{ entry.title }}</h1>
          <p>TEST EDIT 8</p>
          {% for block in entry.blogPost %}
              {% if block.type == 'imageCaption' %}
                  <p>heading - {{ block.heading }}</p>
                  <p>sub heading - {{ block.subHeading }}</p>
              {% elseif block.type == 'WhateverTypeAccoladeIsIn' %}
                  <p>accolade- {{ block.accolade }}</p>
              {% endif %}
          {% endfor %}
  
          <p>Posted on {{ entry.postDate.format('F d, Y') }}</p>
          {{ entry.body }}
      </article>
  {% endblock %}
  
  ```
  
  You should add that check before `block.accolade` as well for whichever block type accolade is in.
  
  
  ---
  
  