I'm on Magento 2.1.6. The header links are rendered with this structure:
<ul class="header links">
<li>...</li>
<li>...</li>
...
</ul>
My HTML structure is like this:
How can I remove ul
tag?? I do not require ul
tag.
You can change Links.php at this location :- vendor/magento/framework/View/Element/Html
Probably on line no 76 remove the UL or change it to DIV
I am extending the answer given by Manoj..
It is required to create a custom module, let us say Stack_Links, follow this link for the same Dev Doc
Then create di.xml file within \app\code\Stack\Links\etc directory of module as below:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Framework/ObjectManager/etc/config.xsd">
<preference for="Magento\Framework\View\Element\Html\Links" type="Stack\Links\Block\Links" />
</config>
Then Copy
\Magento\Framework\View\Element\Template\Links.php
file to
\app\code\Stack\Links\Block\Links.php
Then modify _toHtml() method according to requirement such as below to remove UL tag.
protected function _toHtml()
{
if (false != $this->getTemplate()) {
return parent::_toHtml();
}
$html = '';
if ($this->getLinks()) {
foreach ($this->getLinks() as $link) {
$html .= $this->renderLink($link);
}
}
return $html;
}