Skip to content

Commit

Permalink
Update docs for 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wilr committed Apr 5, 2013
1 parent 9cbc0f2 commit 84d70b1
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions docs/en/StaticPublisher.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,31 @@ which time they are considered outdated. By adding a custom method
caching, and hook in custom logic. This array of URLs is used by the publisher
to generate folders and HTML-files.

First add the FilesystemPublisher extension to your object. See the
[DataExtension](http://doc.silverstripe.org/framework/en/reference/dataextension)
documentation for more ways to add the extension to your SiteTree.

:::php
SiteTree::add_extension("FilesystemPublisher('cache/')");

Once you've added the extension, define the pages you would like to cache from
your Page class:

:::php
class Page extends SiteTree {
// ...

/**

* Return a list of all the pages to cache
*
* @return array
*/
public function allPagesToCache() {
// Get each page type to define its sub-urls
$urls = array();

// memory intensive depending on number of pages
$pages = SiteTree::get();
$pages = Page::get();

foreach($pages as $page) {
$urls = array_merge($urls, (array)$page->subPagesToCache());
Expand All @@ -54,7 +65,9 @@ to generate folders and HTML-files.
}

/**
* Get a list of URLs to cache related to this page
* Get a list of URLs to cache related to this page.
*
* @return array
*/
public function subPagesToCache() {
$urls = array();
Expand All @@ -64,17 +77,22 @@ to generate folders and HTML-files.
// cache the RSS feed if comments are enabled
if ($this->ProvideComments) {
$urls[] = Director::absoluteBaseURL() . "pagecomment/rss/" . $this->ID;
$urls[] = Director::absoluteBaseURL() . "CommentingController/rss/SiteTree/" . $this->ID;
}
return $urls;
}
/**
* Get a list of URL's to publish when this page changes
*/
public function pagesAffectedByChanges() {
$urls = $this->subPagesToCache();
if($p = $this->Parent) $urls = array_merge((array)$urls, (array)$p->subPagesToCache());
return $urls;
}


}

## Excluding Pages
Expand Down

0 comments on commit 84d70b1

Please sign in to comment.