Add content to the ItemList
public addContent ( Content $content, |
||
$content | Content | Content object |
$children | Children | |
$itemAttributes | array | Attributes for the item (li) |
$itemElement | string | Element for the item (li is default) |
$beforeContent | string | String to add before the content |
$afterContent | string | String to add after the content |
public function breadcrumbs() { // Collect all items $activeItem = $this->findActiveItem(); $separator = $this->getOption('item_list.breadcrumb_separator'); // Make the breadcrumbs $itemList = new ItemList(array(), 'breadcrumbs'); // Fill her up if we found the active link if (!is_null($activeItem)) { // Add the found item $itemList->addContent($activeItem->getContent()); // Loop throught the parents until we hit the root while ($nextItem = $activeItem->getParent()) { if (is_null($nextItem->getParent())) { break; } // Add a separator and the link if (!empty($separator)) { $itemList->raw($separator); } $itemList->addContent($nextItem->getParent()->getContent()); // Set the activeItem for the next iteration $activeItem = $nextItem->getParent(); } } // Correct order $itemList->reverse(); return $itemList; }