mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
parents-merge 34566 - Moved Level() from ContentController to SiteTree so that it can be accessed from anywhere
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@45047 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
afbca3a88f
commit
a26099f6f5
@ -154,20 +154,6 @@ class ContentController extends Controller {
|
||||
|
||||
return new DataObjectSet($visible);
|
||||
}
|
||||
/**
|
||||
* Returns the page in the current page stack of the given level.
|
||||
* Level(1) will return the main menu item that we're currently inside, etc.
|
||||
*/
|
||||
|
||||
public function Level($level) {
|
||||
$parent = $this->data();
|
||||
$stack = array($parent);
|
||||
while($parent = $parent->Parent) {
|
||||
array_unshift($stack, $parent);
|
||||
}
|
||||
|
||||
return isset($stack[$level-1]) ? $stack[$level-1] : null;
|
||||
}
|
||||
|
||||
public function Menu($level) {
|
||||
return $this->getMenu($level);
|
||||
|
@ -1347,7 +1347,20 @@ class SiteTree extends DataObject {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the page in the current page stack of the given level.
|
||||
* Level(1) will return the main menu item that we're currently inside, etc.
|
||||
*/
|
||||
public function Level($level) {
|
||||
$parent = $this;
|
||||
$stack = array($parent);
|
||||
while($parent = $parent->Parent) {
|
||||
array_unshift($stack, $parent);
|
||||
}
|
||||
|
||||
return isset($stack[$level-1]) ? $stack[$level-1] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the CSS classes to apply to this node in the CMS tree
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user