1

Receiving the standard error:

Craft\MatrixBlockModel and its behaviors do not have a method or closure named "sectionArticles".

The problem is that this error doesn't make sense. Here is why:

  1. I have a newsletter template with the block 'sectionArticles'
  2. It lists entries from 3 different sections
  3. These 3 sections do not have a block 'sectionArticles' nor a reference to it in their templates.
  4. If I click on a link that leads to the url for these entries, I receive the above error
  5. If I copy and paste the url into a new tab everything is fine
  6. This only recently started happening. In other words, old issues of the newsletter are fine

Help?

Here is code for referring template:

{% for block in entry.connectionsContent %}
  {% switch block.type %}
    {% case "connectionsTextOnly" %}
      <div class="{{ block.backgroundColor }} page-section">
        <div class="row">
          {% set asset = block.sectionImage.first() %}
          {% if asset %}
            <div class="large-3 medium-4 small-12 columns large-push-9 medium-push-8">
              <img src="{{ asset.url }}">
            </div>
            <div class="large-9 medium-8 small-12 columns large-pull-3 medium-pull-4">
          {% else %}
            <div class="small-12 columns">
          {% endif %}
              {{ block.sectionText }}
            </div>
          </div>
        </div>
    {% default %}
      {% set entries = block.sectionArticles %}
      {% if entries | length %}
        <div class="{{ block.backgroundColor }} page-section article-grid">
          <div class="row large-up-4 medium-up-2" data-equalizer data-equalize-on="medium">
            {% for entry in entries %}
              {% if entry.section.handle == "news" %}
                {% include 'news/_includes/feed' %}
              {% elseif entry.section.handle == "pages" %}
                {% include 'pages/_includes/feed' %}
              {% elseif entry.section.handle == "events" %}
                {% include 'events/_includes/feed' %}
              {% endif %}
            {% endfor %}
          </div>
        </div>
      {% endif %}
    {% endswitch %}
{% endfor %}

The feed templates are just links and display fine.

The errors occurs on the events/_entry, news/_entry and pages/_entry templates. There is no references of the block 'sectionArticles' in those templates.

One more thing: the error only happens on scheduled entries, where the Post Date is in the future, after the Post Date has arrived.

  • can you please share the template code that seems to be throwing this error? – Jalen Davenport May 14 '18 at 15:03
  • How is block getting defined in your template? Are you looping through all of your Matrix blocks? – Brad Bell May 14 '18 at 23:20
  • I updated above to include the block and switch. After further research, it turns out that the error is thrown only when a "connectionsTextOnly" block exists. Still doesn't answer the question of why it throws the error after you leave – Jono May 15 '18 at 20:59
  • By using {% default %}, you're saying that every block not named connectionsTextOnly is going to have a sectionArticles field in it... is that the case? – Brad Bell May 16 '18 at 0:01
  • correct. There are only two block types. – Jono May 17 '18 at 0:47
1

Thanks everyone for taking a look. I forgot that I had implemented something on the receiving templates that allowed you to navigate between articles from the newsletter, if the referral url was the newsletter. After I implemented the text only block, I forgot to change this to ignore those blocks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.