Skip to content

Commit

Permalink
Overwrites Current Link block to fit bootstrap markup
Browse files Browse the repository at this point in the history
  • Loading branch information
mmenozzi committed May 14, 2017
1 parent 8fa1ea0 commit fc9a32e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
39 changes: 39 additions & 0 deletions View/Element/Html/Link/Current.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Webgriffe\BootstrapMenu\View\Element\Html\Link;

class Current extends \Magento\Framework\View\Element\Html\Link\Current
{
protected function _toHtml()
{
if (false != $this->getTemplate()) {
return parent::_toHtml();
}

$highlight = '';

if ($this->getIsHighlighted() || $this->isCurrent()) {
$highlight = ' active';
}

$html = '<li class="nav item' . $highlight . '"><a href="' . $this->escapeHtml($this->getHref()) . '"';
$html .= $this->getTitle()
? ' title="' . $this->escapeHtml((string)new \Magento\Framework\Phrase($this->getTitle())) . '"'
: '';
$html .= $this->getAttributesHtml() . '>';

if ($this->getIsHighlighted()) {
$html .= '<strong>';
}

$html .= $this->escapeHtml((string)new \Magento\Framework\Phrase($this->getLabel()));

if ($this->getIsHighlighted()) {
$html .= '</strong>';
}

$html .= '</a></li>';

return $html;
}
}
1 change: 1 addition & 0 deletions etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Theme\Block\Html\Topmenu" type="Webgriffe\BootstrapMenu\Block\Html\Topmenu" />
<preference for="Magento\Framework\View\Element\Html\Link\Current" type="Webgriffe\BootstrapMenu\View\Element\Html\Link\Current" />
</config>

0 comments on commit fc9a32e

Please sign in to comment.