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:
- I have a newsletter template with the block 'sectionArticles'
- It lists entries from 3 different sections
- These 3 sections do not have a block 'sectionArticles' nor a reference to it in their templates.
- If I click on a link that leads to the url for these entries, I receive the above error
- If I copy and paste the url into a new tab everything is fine
- 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.
block
getting defined in your template? Are you looping through all of your Matrix blocks?{% default %}
, you're saying that every block not namedconnectionsTextOnly
is going to have asectionArticles
field in it... is that the case?