Permalink
Browse files

ENHANCEMENT Added SiteTree->getStageURLSegment() and SiteTree->getLiv…

…eURLSegment() to allow auto-population in the CMS edit form. This information is necessary to keep clientside UI state consistent.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@92531 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 9ecd359 commit 0abe4728d159a71c473f5bb3b4c7b53a530d620d @chillu chillu committed Nov 21, 2009
Showing with 32 additions and 0 deletions.
  1. +32 −0 core/model/SiteTree.php
View
@@ -1446,7 +1446,39 @@ function generateURLSegment($title){
}
/**
+ * @return string
+ */
+ function getStageURLSegment() {
+ $stageRecord = Versioned::get_one_by_stage(
+ 'SiteTree',
+ 'Stage',
+ "\"SiteTree\".\"ID\" = $this->ID"
+ );
+ return ($stageRecord) ? $stageRecord->URLSegment : null;
+ }
+
+ /**
+ * @return string
+ */
+ function getLiveURLSegment() {
+ $liveRecord = Versioned::get_one_by_stage(
+ 'SiteTree',
+ 'Live',
+ "\"SiteTree\".\"ID\" = $this->ID"
+ );
+ return ($liveRecord) ? $liveRecord->URLSegment : null;
+ }
+
+ /**
+ * Return the SiteTree object with the given URL segment.
+ *
* @deprecated 2.4 Use {@link SiteTree::get_by_link()}.
+ *
+ * @param string $urlSegment The URL segment, eg 'home'
+ * @param string $extraFilter
+ * @param boolean $cache
+ * @param string $orderby
+ * @return SiteTree The object with the given URL segment
*/
public static function get_by_url($link) {
user_error (

0 comments on commit 0abe472

Please sign in to comment.