Which I think should cache every page, apart from those with the page builder, where the full-newsletter-signup-form block has been used. I have tested this with a simple if statement on the pages, and it seems to be returning true/false on the right pages.
However, when I look at the cache there are only a few pages in there, not all the ones I would expect. What triggers a page being added? I have visited them in browser but that doesn’t seem to have done it
Thanks for the reply, that is what I thought. For some reason only some pages are being cached, though I think my function is doing what it should. I will keep at it
Ok I can’t work this out. For some reason subpages in my news directory are being cached, but all others are not. I have dropped my function in the header of all my pages like so:
if($page->pageBuilder()->toBlocks()->filterBy('type', 'full-newsletter-signup-form')->isNotEmpty()):
echo "this page will be ignored";
else:
echo "this page will be cached";
endif;
And that is doing what I would expect, it is saying a page will be cached if (a) it doesn’t have the pagebuilder field or (b) it has it, but doesn’t use the full-newsletter-signup-form block.
Have you tried to watch the cache folder while you are trying to open each page? Is the complete cache cleared at some point maybe due to updates happening in the background, e.g. hooks or models or pluins that update something, thus clearing the cache?
I tested the cache in a fresh Starterkit with slightly adapted code (because the starterkit doesn’t have your custom block. So in config, I put this:
Sorry for the delayed reply. I have watched the cache folder while navigating the site, and only the subpages in the /news section are cached, all others are not.
I don’t have any hooks on this site, I have some fairly simple controllers to handle Uniform submissions but not anything beyond that.
Hm, can’t tell from here what is happening. Feel free to send me a download link to your project via PM if you can, then I could take a look to see if I can find the issues.