mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-01 05:39:36 +02:00
FEATURE: move breadcrumbs out to a customizable template
This commit is contained in:
parent
95f35cc0d2
commit
8fe767b5f2
@ -154,13 +154,6 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
"Versioned('Stage', 'Live')",
|
"Versioned('Stage', 'Live')",
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* Delimit breadcrumb-links generated by BreadCrumbs()
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public static $breadcrumbs_delimiter = " » ";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not to write the homepage map for static publisher
|
* Whether or not to write the homepage map for static publisher
|
||||||
*/
|
*/
|
||||||
@ -625,24 +618,25 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
*/
|
*/
|
||||||
public function Breadcrumbs($maxDepth = 20, $unlinked = false, $stopAtPageType = false, $showHidden = false) {
|
public function Breadcrumbs($maxDepth = 20, $unlinked = false, $stopAtPageType = false, $showHidden = false) {
|
||||||
$page = $this;
|
$page = $this;
|
||||||
$parts = array();
|
$pages = array();
|
||||||
$i = 0;
|
|
||||||
while(
|
while(
|
||||||
$page
|
$page
|
||||||
&& (!$maxDepth || sizeof($parts) < $maxDepth)
|
&& (!$maxDepth || count($pages) < $maxDepth)
|
||||||
&& (!$stopAtPageType || $page->ClassName != $stopAtPageType)
|
&& (!$stopAtPageType || $page->ClassName != $stopAtPageType)
|
||||||
) {
|
) {
|
||||||
if($showHidden || $page->ShowInMenus || ($page->ID == $this->ID)) {
|
if($showHidden || $page->ShowInMenus || ($page->ID == $this->ID)) {
|
||||||
if(($page->ID == $this->ID) || $unlinked) {
|
$pages[] = $page;
|
||||||
$parts[] = Convert::raw2xml($page->Title);
|
|
||||||
} else {
|
|
||||||
$parts[] = ("<a href=\"" . $page->Link() . "\">" . Convert::raw2xml($page->Title) . "</a>");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = $page->Parent;
|
$page = $page->Parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode(self::$breadcrumbs_delimiter, array_reverse($parts));
|
$template = new SSViewer('BreadcrumbsTemplate');
|
||||||
|
|
||||||
|
return $template->process($this->customise(new ArrayData(array(
|
||||||
|
'Pages' => new ArrayList(array_reverse($pages))
|
||||||
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
5
templates/BreadcrumbsTemplate.ss
Normal file
5
templates/BreadcrumbsTemplate.ss
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<% if Pages %>
|
||||||
|
<% control Pages %>
|
||||||
|
<% if Last %>$Title.XML<% else %><a href="$Link">$MenuTitle.XML</a> »<% end_if %>
|
||||||
|
<% end_control %>
|
||||||
|
<% end_if %>
|
Loading…
Reference in New Issue
Block a user