caching - silverstripe static publisher - pages affected by DataObject Changes -
is there possibility trigger update of cache if dataobject edited? example updating news dataobject should update cache of pages, displaying these newsobjects.
many thanx, florian
here using staticpublishqueue module. in newsdataobject.php:
function onafterwrite() { parent::onafterwrite(); $url = array(); $pages = $this->pages(); //has_many link pages include dataobject foreach($pages $page) { $pagesaffected = $page->pagesaffected(); if ($pagesaffected && count($pagesaffected) > 0) { $urls = array_merge((array)$urls, (array)$pagesaffected); } } urlarrayobject::add_urls($urls); }
this takes each of pages references dataobject, asks it's url , url of related pages (e.g. virtual pages reference page), compiles urls big array, adds array static publishing queue. queue gradually process until affected pages republished.
the event system allows add layer of abstraction between republishing , triggers republishing, simple don't need use it. instead, can add pages queue directly. (you might read blog post describing staticpublishqueue module)
Comments
Post a Comment