mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Default priority is now based on a page's depth in the site tree, but can be overwritten.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@44513 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
491efc6d75
commit
c32493a550
@ -123,8 +123,6 @@ class SiteTree extends DataObject {
|
||||
"ShowInSearch" => 1,
|
||||
"Status" => "New page",
|
||||
"CanCreateChildren" => array(10),
|
||||
"Priority" => 0.5,
|
||||
|
||||
"Viewers" => "Anyone",
|
||||
"Editors" => "LoggedInUsers"
|
||||
);
|
||||
@ -894,6 +892,19 @@ class SiteTree extends DataObject {
|
||||
self::$cms_additions[] = $function;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default value of the priority field depends on the depth of the page in
|
||||
* the site tree, so it must be calculated dynamically.
|
||||
*/
|
||||
function getPriority() {
|
||||
if($this->getField('Priority') === null) {
|
||||
$parentStack = $this->parentStack();
|
||||
$numParents = is_array($parentStack) ? count($parentStack) - 1: 0;
|
||||
return max(0.1, 1.0 - ($numParents / 10));
|
||||
}
|
||||
|
||||
return $this->getField('Priority');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a FieldSet with which to create the CMS editing form.
|
||||
@ -973,7 +984,7 @@ class SiteTree extends DataObject {
|
||||
|
||||
|
||||
$pagePriorities = array(
|
||||
'0' => _t('SiteTree.PRIORITYNOTINDEXED', "Not indexed"),
|
||||
'0.0' => _t('SiteTree.PRIORITYNOTINDEXED', "Not indexed"),
|
||||
'1.0' => '1 - ' . _t('SiteTree.PRIORITYMOSTIMPORTANT', "Most important"),
|
||||
'0.9' => '2',
|
||||
'0.8' => '3',
|
||||
|
Loading…
Reference in New Issue
Block a user