diff --git a/code/SiteTreeSubsites.php b/code/SiteTreeSubsites.php index 2bc4e4b..249e1d4 100644 --- a/code/SiteTreeSubsites.php +++ b/code/SiteTreeSubsites.php @@ -190,17 +190,41 @@ class SiteTreeSubsites extends SiteTreeDecorator { $related->setPermissions(array('add', 'edit', 'delete')); if($reverse) { - $text = '

In addition, this page is marked as related by the following pages:

'; + $text = '

In addition, this page is marked as related by the following pages:

'; $tab->push(new LiteralField('ReverseRelated', $text)); } } + function ReverseRelated() { + $return = new DataObjectSet(); + $links = DataObject::get('RelatedPageLink', 'RelatedPageID = ' . $this->owner->ID); + if($links) foreach($links as $link) { + if($link->MasterPage()->exists()) { + $return->push($link->MasterPage()); + } + } + + return $return->Count() > 0 ? $return : false; + } + + function NormalRelated() { + $return = new DataObjectSet(); + $links = DataObject::get('RelatedPageLink', 'MasterPageID = ' . $this->owner->ID); + if($links) foreach($links as $link) { + if($link->RelatedPage()->exists()) { + $return->push($link->RelatedPage()); + } + } + + return $return->Count() > 0 ? $return : false; + } + /** * Returns the RelatedPageLink objects that are reverse-associated with this page. */ @@ -336,6 +360,14 @@ class SiteTreeSubsites extends SiteTreeDecorator { return $url; } + + /** + * Return a piece of text to keep DataObject cache keys appropriately specific + */ + function cacheKeyComponent() { + return 'subsite-'.Subsite::currentSubsiteID(); + } + function augmentSyncLinkTracking() { // Set LinkTracking appropriately $links = HTTP::getLinksIn($this->owner->Content); @@ -366,13 +398,6 @@ class SiteTreeSubsites extends SiteTreeDecorator { $this->owner->CrossSubsiteLinkTracking()->setByIDList($linkedPages); } - - /** - * Return a piece of text to keep DataObject cache keys appropriately specific - */ - function cacheKeyComponent() { - return 'subsite-'.Subsite::currentSubsiteID(); - } } ?>