Add a item to the default menu
Menu::add('home', 'Homepage');
Add a item with a subitem to the default menu
Menu::add('home', 'Homepage', Menu::items()->add('home/sub', 'Subitem'));
Add a item with attributes for the item's HTML element
Menu::add('home', 'Homepage', null, array('class' => 'fancy'));
public add ( string $url, string $value, |
||
$url | string | Url of the link |
$value | string | (H)T(ML) inside of the link |
$children | Children | |
$linkAttributes | array | Attributes for the link |
$itemAttributes | array | Attributes for the item |
$itemElement | string | The element for the item |
$beforeContent | string | String to add before the link |
$afterContent | string | String to add after the link |
return |
public function add($url, $value, $children = null, $linkAttributes = array(), $itemAttributes = array(), $itemElement = null, $beforeContent = null, $afterContent = null)
{
$content = new Link($url, $value, $linkAttributes);
$item = $this->addContent($content, $children, $itemAttributes, $itemElement, $beforeContent, $afterContent);
return $this;
}
public function testMenuCanSetGlobalOptions() { Menu::setOption('item.element', 'dl'); $list = new ItemList(); $list->add('#', 'foo'); $this->assertHTML($this->matchListWithItem('ul', 'dl'), $list->render()); $this->assertHTML($this->matchLink(), $list->render()); }