schafdog27 Posted February 10, 2015 Posted February 10, 2015 Hi all, quick question. Is there a way to clear the template cache when a page using a specific template is sorted with drag-and-drop? I see you can clear it when a page is saved, but there doesn't seem to be an option for when it is sorted. It's not a big deal if there is not, as I can just go in and save a page and the cache will be cleared. Just wondering if I'm missing something. Sorry if this has already been asked. I googled, but couldn't find anything. 1
LostKobrakai Posted February 10, 2015 Posted February 10, 2015 If you mean sorting in the page-tree than it should work with clearing on page save. The new position has be be saved in some way, which should trigger the cache clear. It can only be, that it's only the parent page which is saved, as the children are sorted.
schafdog27 Posted February 10, 2015 Author Posted February 10, 2015 If you mean sorting in the page-tree than it should work with clearing on page save. The new position has be be saved in some way, which should trigger the cache clear. It can only be, that it's only the parent page which is saved, as the children are sorted. Thanks for the reply. That's kind of what I thought, but unless I'm doing something wrong, it's not working. For example, I have 4 pages using a template called 'basic-page' which are direct children of the homepage. All of them show up in the top menu of the site. I set the homepage template cache to clear on save and rearrange the pages using the 'basic-page' template. When I reload the homepage, I cannot see the changes (in the top menu) until I go in and physically save the homepage.
LostKobrakai Posted February 10, 2015 Posted February 10, 2015 Than my theory was wrong, never had to check where sorting is actually saved. What will always work is if you use this blueprint https://processwire-recipes.com/recipes/extending-page-save-process/ and add the code to clear the cache when specific pages are saved. 1
schafdog27 Posted February 11, 2015 Author Posted February 11, 2015 Than my theory was wrong, never had to check where sorting is actually saved. What will always work is if you use this blueprint https://processwire-recipes.com/recipes/extending-page-save-process/ and add the code to clear the cache when specific pages are saved. Thanks, that got me on the right track. I was able to clear the cache by hooking after ProcessPageSort::execute. public function init() { $this->addHookAfter('ProcessPageSort::execute', $this, 'afterSort'); } public function afterSort() { $homePage = wire("pages")->get("template=home"); $pageRender = wire("modules")->get("PageRender"); $cacheFile = $pageRender->getCacheFile($homePage); $cacheFile->expireAll(); }
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now