Closed dadaxr closed 7 months ago
Unfortunately this is a huge issue. I had this several times. It also affects custom variables ({{ items = {collection ...} }}
) which are all put into the context and can't be serialized, when paginated.
If you can put the iterated code into a partial, there's a workaround:
{{ collection:recettes video:exists="true" paginate="20" as="items" }}
{{ items }}
{{ partial src="..." :paginate="null" }}
{{ /items }}
{{ /collection:recettes }}
Partial's content:
{{ title }}
{{ nocache }}
This should work.
{{ /nocache }}
Besides that, the pagination in general does not work well with {{ nocache }}
.
If you wrap the whole collection + the pagination in a {{ nocache }}
tag pair, you'll get links like example.com/!/nocache?page=2
.
{{ nocache }}
{{ collection:pages paginate="10" }}
<ul>
{{ entries }}
<li>
{{ title }}
</li>
{{ /entries }}
</ul>
{{ paginate }}
<!-- Will only work on first impression & will not work as expected, when served from cache. -->
Next Page URL: {{ next_page }}
{{ /paginate }}
{{ /collection:pages }}
{{ /nocache }}
passing a null "paginate" param to a partial is a nice trick ! (when it can be done)
Thanks for sharing the pagination link issue, I'll have a look next time !
I have also had this issue.
Bug description
As mentioned in the title, using a nocache tag pair after a calling a collection tag using a "paginate" param, fails !
I guess the paginate param create some closures somewhere in the global context and the nocache tag tries to "capture" it but fails...
How to reproduce
just put the bellow code in a template
however the bellow examples dont trigger any error :
If we use a "classical" collection tag syntax :
however if we use a nocache tag inside the tag pair :
To give a concrete example : I have a list of receipt and that I want to show on a listing page. everything can be cached, except one value of each receipt (the rating) which can change dynamically. So I have that collection tag pair with a "nocache" tag inside it surrounding the rating part... and here comes the closure serialization error.
I dont know what can be done to resolve this issue ?
Logs
No response
Environment
Installation
Fresh statamic/statamic site via CLI
Antlers Parser
runtime (new)
Additional details
No response