Skip to content

Commit

Permalink
Better customization option with the separator
Browse files Browse the repository at this point in the history
  • Loading branch information
HavokInspiration committed Oct 3, 2016
1 parent 04dc55e commit 7338e06
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/View/Helper/BreadcrumbsHelper.php
Expand Up @@ -43,8 +43,8 @@ class BreadcrumbsHelper extends Helper
protected $_defaultConfig = [
'templates' => [
'wrapper' => '<ul{{attrs}}>{{content}}</ul>',
'item' => '<li{{attrs}}><a href="{{link}}"{{innerAttrs}}>{{title}}</a></li>',
'itemWithoutLink' => '<li{{attrs}}><span{{innerAttrs}}>{{title}}</span></li>',
'item' => '<li{{attrs}}><a href="{{link}}"{{innerAttrs}}>{{title}}</a></li>{{separator}}',
'itemWithoutLink' => '<li{{attrs}}><span{{innerAttrs}}>{{title}}</span></li>{{separator}}',
'separator' => '<li{{attrs}}><span{{innerAttrs}}>{{separator}}</span></li>'
]
];
Expand Down Expand Up @@ -222,17 +222,18 @@ public function render(array $attributes = [], array $separator = [])
'innerAttrs' => $templater->formatAttributes($optionsLink),
'title' => $title,
'link' => $link,
'separator' => '',
];

if (empty($link)) {
$template = 'itemWithoutLink';
}

$crumbTrail .= $this->formatTemplate($template, $templateParams);

if (isset($separatorParams) && $key !== ($crumbsCount-1)) {
$crumbTrail .= $this->formatTemplate('separator', $separatorParams);
$templateParams['separator'] = $this->formatTemplate('separator', $separatorParams);
}

$crumbTrail .= $this->formatTemplate($template, $templateParams);
}

$crumbTrail = $this->formatTemplate('wrapper', [
Expand Down
1 change: 0 additions & 1 deletion tests/TestCase/View/Helper/BreadcrumbsHelperTest.php
Expand Up @@ -301,7 +301,6 @@ public function testRenderCustomTemplate()
'wrapper' => '<ol itemtype="http://schema.org/BreadcrumbList"{{attrs}}>{{content}}</ol>',
'item' => '<li itemprop="itemListElement" itemtype="http://schema.org/ListItem"{{attrs}}><a itemtype="http://schema.org/Thing" itemprop="item" href="{{link}}"{{innerAttrs}}><span itemprop="name">{{title}}</span></a></li>',
'itemWithoutLink' => '<li itemprop="itemListElement" itemtype="http://schema.org/ListItem"{{attrs}}><span itemprop="name"{{innerAttrs}}>{{title}}</span></li>',
'separator' => ''
]
]);
$this->breadcrumbs
Expand Down

0 comments on commit 7338e06

Please sign in to comment.