Permalink
Browse files

Add parameter to allow breadcrumb to optionally enable linking of fin…

…al crumb.
  • Loading branch information...
1 parent daf6c81 commit b6dcba1dcb37a0b48074502b1a00eb284ba25804 @apinstein committed Aug 2, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −4 phocoa/framework/widgets/WFBreadCrumb.php
View
9 phocoa/framework/widgets/WFBreadCrumb.php
@@ -315,7 +315,7 @@ public function addBreadCrumbNode($bcNode)
* @param object WFObject The instance to create the breadcrumb for.
* @return array A hash of title => url for all items in the breadcrumb.
*/
- public function getBreadCrumb($object)
+ public function getBreadCrumb($object, $showLinkOnFinal = false)
{
// unroll decorated objects
while ($object instanceof WFDecorator) {
@@ -330,10 +330,11 @@ public function getBreadCrumb($object)
// build breadcrumb
$breadcrumb = array(); // will be linkTitle => linkURL
+ $minCountToEnableLink = $showLinkOnFinal ? 0 : 1;
while (true) {
$decoratedObject = $node->decorateObject($object);
$title = $decoratedObject->valueForKeyPath($node->valueForKey('linkTextKeyPath'));
- if (count($breadcrumb) > 0)
+ if (count($breadcrumb) >= $minCountToEnableLink)
{
$url = $node->getLinkURL($decoratedObject);
}
@@ -364,10 +365,10 @@ public function getBreadCrumb($object)
* @param object WFObject The instance to create the breadcrumb for.
* @return string The HTML for the breadcrumb.
*/
- public function renderBreadCrumb($object)
+ public function renderBreadCrumb($object, $showLinkOnFinal = false)
{
$html = NULL;
- foreach ($this->getBreadCrumb($object) as $linkText => $linkURL) {
+ foreach ($this->getBreadCrumb($object, $showLinkOnFinal) as $linkText => $linkURL) {
if ($html !== NULL)
{
$html .= ' ' . $this->separator . ' ';

0 comments on commit b6dcba1

Please sign in to comment.