public function render($attributes = array()) { if (!$this->label) { throw new Exception('Missing menu label'); } // create label with tag "a" $a = new Element('a', $this->linkAttributes); $a->setAttributeValue("role", "menuitem"); $a->appendText($this->label); $this->append($a); return parent::render($attributes); }
/** * Append a link "a" element and add "span" element wrapper with microdata automatically. * * @param string $label The label of that link. * @param string $url The url of that link. * @param string $title The title attribute of the link. * @param array $attributes The attributes of the link. */ public function appendLink($label, $url, $title = NULL, array $attributes = array()) { $span = new Element('span'); $span['itemscope'] = NULL; $span['itemtype'] = 'http://data-vocabulary.org/Breadcrumb'; $span['role'] = 'presentation'; $a = new Element('a', $attributes); $a['title'] = $title ?: $label; $a['alt'] = $title ?: $label; $a['itemprop'] = 'url'; $a['href'] = $url; $a['aria-level'] = $this->getChildrenSize() + 1; # <span itemprop="title">Home</span> $title = new Element('span'); $title->appendText($label); $title['itemprop'] = 'title'; $a->addChild($title); $span->addChild($a); $this->addChild($span); return $span; }
public function render($attrs = array()) { // create a wrapper div // <div itemscope itemtype="http://schema.org/SiteNavigationElement"> if (!$this->label) { throw new Exception('Missing menu label'); } // create label with tag "a" $a = new Element('a'); $a->appendText($this->label); $this->append($a); $this->append($this->menuItemCollection); return parent::render($attrs); }