You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We entrified our installation and use Singles for all "global" tasks. With preloadSingles() in the general.php, the use is very painless.
Now I ran into an issue, that templates don't get invalidated, when e.g. the navigation changes.
To reproduce:
enable preloadSingles()
create a Single "header"
create a Structure "page"
create a field "navigation", which is an entry field for "page"
add that field to "header"
create some pages and put some of them in the header.navigation field
create the navigation template (see below)
you will get Blitz hint for eager loading navigation
add eager loading for "globals" (see below)
now the hint is gone, but the cache no longer refreshes
When I use this syntax {% set header = craft.entries.section('header').with(['navigation']).one() %}, everythings works as expected. But I would prefer to preload the Singles.
In the DB dump (data/db.sql.gz) I already created some pages. So open the website in the browser, get the cache generated. Head to the backend, take one of the pages out of the navigation in the header Single. Run the queue from CLI. Refresh the browser, see no difference.
The backend login is "admin" with password "andres@voan.ch"
Template code
{# Navigation template #}
{% if header.navigation.all() | length %}
<ul>
{% for link in header.navigation.all() %}
<li><a href="{{ link.url }}">{{ link.title }}</a></li>
{% endfor %}
</ul>
{% endif %}
{# Eager load navigation in header #}
{% do craft.app.elements.eagerLoadElements(
className(header),
[header],
['navigation']
) %}
The text was updated successfully, but these errors were encountered:
Thanks, I’m seeing the issue now. I’ll need to troubleshoot where exactly the issue lies. In the meantime I suggest you use the more explicit craft.entries.section('header').with(['navigation']).one().
We entrified our installation and use Singles for all "global" tasks. With
preloadSingles()
in the general.php, the use is very painless.Now I ran into an issue, that templates don't get invalidated, when e.g. the navigation changes.
To reproduce:
preloadSingles()
When I use this syntax
{% set header = craft.entries.section('header').with(['navigation']).one() %}
, everythings works as expected. But I would prefer to preload the Singles.Find an example repo here: https://github.com/vandres/blitz-bug-eager-loading
In the DB dump (data/db.sql.gz) I already created some pages. So open the website in the browser, get the cache generated. Head to the backend, take one of the pages out of the navigation in the header Single. Run the queue from CLI. Refresh the browser, see no difference.
The backend login is "admin" with password "andres@voan.ch"
Template code
The text was updated successfully, but these errors were encountered: