FEATURE: Add a function to give link to Live site (from r95948)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@98102 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-02-04 01:08:15 +00:00
parent 19b745ad9e
commit d64a9c28ca

View File

@ -397,6 +397,25 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
return Controller::join_links($base, '/', $action);
}
/**
* Get the absolute URL for this page on the Live site.
*/
public function getAbsoluteLiveLink($includeStageEqualsLive = true) {
$live = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $this->ID);
if($live) {
$link = $live->AbsoluteLink();
if($includeStageEqualsLive) {
$link .= '?stage=Live';
}
return $link;
}
}
/**
* Return a CSS identifier generated from this page's link.
*