I am running into an odd issue where creating new child entries does not bust the cache of the parent page(s) that lists them.
This is the structure I am working with:
I am displaying the Course
entries on the Course Landing Pages
like so:
{% cache using key craft.request.path %}
{% set currentPage = craft.entries.id(entry.id).first() %}
{% set entries = craft.entries({
type: 'course',
descendantOf: currentPage,
with: [
['courseThumbnail', {
withTransforms: [
{ mode: 'crop', width: 800, height: 800, position: 'center-center', format: 'jpg' }
]
}]
]
}) %}
{% for entry in entries %}
{% include '_includes/_listing-item-course' with { featured : true } %}
{% endfor %}
{% endcache %}
When I publish a new Course
entry, the cache for the parent page(s) is not busted and the new entry will not show unless I move/drag into a new position. This seems to clear the cache and the new entry shows on the parent page(s).
If I change the craft.entries
call to not include the descendantOf
part, so it looks like this:
{% set entries = craft.entries({
type: 'course',
with: [
['courseThumbnail', {
withTransforms: [
{ mode: 'crop', width: 800, height: 800, position: 'center-center', format: 'jpg' }
]
}]
]
}) %}
Then newly added Course
entries will show up straight away on all the Course Landing Pages
.
Why is that?
descendantOf
parameter. If I set entries like this{% set entries = craft.entries.type('course') %}
, new ones show up straight away when published. The moment I change it to this{% set entries = craft.entries.type('course').descendantOf(entry) %}
, they won't show up unless I manually clear the cache or move the new entry’s position in the structure tree. Very odd.