Menu\Items\ItemList::raw PHP Method

raw() public method

Add a raw item to the default main menu Menu::raw('');
public raw ( string $raw, ItemList $children = null, array $itemAttributes = [], string $itemElement = null, string $beforeContent = null, string $afterContent = null ) : ItemList
$raw string The raw content
$children ItemList Children
$itemAttributes array The item attributes
$itemElement string The item element
$beforeContent string String to add before the raw content
$afterContent string String to add after the raw content
return ItemList
    public function raw($raw, $children = null, $itemAttributes = array(), $itemElement = null, $beforeContent = null, $afterContent = null)
    {
        $content = new Raw($raw);
        $item = $this->addContent($content, $children, $itemAttributes, $itemElement, $beforeContent, $afterContent);
        return $this;
    }

Usage Example

Ejemplo n.º 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;
 }