addContent() public méthode

Add content to the ItemList
public addContent ( Content $content, ItemList $children = null, array $itemAttributes = [], string $itemElement = null, string $beforeContent = null, string $afterContent = null )
$content Content Content object
$children ItemList 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
Exemple #1
0
 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;
 }