21278 Posts in 5728 Topics by 2599 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1131 Views |
-
Static Publisher - pagesAffectedByChanges

10 October 2009 at 8:37pm Last edited: 10 October 2009 8:39pm
Static Publisher - pagesAffectedByChanges()
http://doc.silverstripe.com/doku.php?id=staticpublisherWill someone be so kind and show me an example of setting so when I publish ArticlePage, both ArticleHolder & HomePage get rebuilt too.
I did find an example where every page get's rebuilt when any page is published, but it seemed a little slow on a site with a lot of pages.
thank you
-
Re: Static Publisher - pagesAffectedByChanges

10 October 2009 at 8:46pm Last edited: 31 October 2009 9:31pm
I'm pretty sure all you just need to return an array of urls to recache. So for example
function pagesAffectedByChanges($original = null) {
$urls[] = ""; // update the homepage
$urls[] = $this->Parent()->Link(); // update the parent page (article holder)
$urls[] = $this->Link(); // this page
return $urls; // pass it back
} -
Re: Static Publisher - pagesAffectedByChanges

31 October 2009 at 9:01pm Last edited: 31 October 2009 9:01pm
Thanks willr for the help,
If I need it for any other page, do I just refer to it's class name?
function pagesAffectedByChanges($original = null) {
$urls[] = "LinksPage";
}The example code has some array_merge in there , do I not need to do that?
if($p = $this->Parent) $urls = array_merge((array)$urls, (array)$p->subPagesToCache());
And I'm not understanding what the $original is doing?
-
Re: Static Publisher - pagesAffectedByChanges

31 October 2009 at 9:30pm
If I need it for any other page, do I just refer to it's class name?
No, $urls takes an array of URLs you would like to cache.
And I'm not understanding what the $original is doing?
$original is the previous saved state of the page this is useful for doing your own custom detection. For example depending on fields that have changed (eg $URLSegment is different), the pages that have been affected by that change could be different.
The example code has some array_merge in there
You would only need to do that if you needed to merge 2 arrays. That code you posted has another function subPagesToCache() which needs to have its values merged with the current function.
| 1131 Views | ||
|
Page:
1
|
Go to Top |


