Page 2 of 2
Re: Add an external link to a category (Menu)
Posted: Fri Mar 23, 2018 12:54 am
by Livakee
Check this out:
https://www.templatemonster.com/help/op ... -menu.html
but I cannot find anything related to the "$categories" in the header.twig
or here is something slightly different:
viewtopic.php?t=93015
or this mod, but not for version 3.x
https://www.opencart.com/index.php?rout ... n_id=26321
Re: Add an external link to a category (Menu)
Posted: Fri Mar 23, 2018 1:06 am
by straightlight
or here is something slightly different: viewtopic.php?t=93015
Inaccurate solution since the OP did not confirmed the posted solution.
Even though the extension is not for v3.x releases, you can use the Template Switcher extension on the Marketplace to still use the TPL files rather than the default TWIG files.
Re: Add an external link to a category (Menu)
Posted: Sat Mar 24, 2018 3:34 am
by Livakee
Thank you. But i suppose even though i cannot use the v2.x extension, right?
Re: Add an external link to a category (Menu)
Posted: Sat Mar 24, 2018 4:32 am
by straightlight
The answer is ... right on the above ...
Re: Add an external link to a category (Menu)
Posted: Tue Oct 09, 2018 12:35 am
by FCWC
catalog/view/theme//template/common/menu.twig
To input custom links into Category section OC 3.0.2
Re: Add an external link to a category (Menu)
Posted: Fri Sep 06, 2019 7:24 pm
by nuggzy
FCWC wrote: ↑Tue Oct 09, 2018 12:35 am
catalog/view/theme//template/common/menu.twig
To input custom links into Category section OC 3.0.2
an example would have been nice
Re: Add an external link to a category (Menu)
Posted: Sat Sep 07, 2019 7:48 am
by webocreation.com
If you are looking to modify the code and add the link at the end of the categories then you can add like <li><a href="https://www.google.com">Forum</a></li> near the end of the catalog/view/theme//template/common/menu.twig
Example:
Code: Select all
{% if categories %}
<div class="container">
<nav id="menu" class="navbar">
<div class="navbar-header">
<span id="category" class="visible-xs">{{ text_category }}</span>
<button type="button" class="btn btn-navbar navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<i class="fa fa-bars"></i>
</button>
</div>
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
{% for category in categories %}
{% if category.children %}
<li class="dropdown">
<a href="{{ category.href }}" class="dropdown-toggle" data-toggle="dropdown">{{ category.name }}</a>
<div class="dropdown-menu">
<div class="dropdown-inner">
{% for children in category.children|batch(category.children|length / category.column|round(1, 'ceil')) %}
<ul class="list-unstyled">
{% for child in children %}
<li>
<a href="{{ child.href }}">{{ child.name }}</a>
</li>
{% endfor %}
</ul>
{% endfor %}
</div>
<a href="{{ category.href }}" class="see-all">{{ text_all }}
{{ category.name }}</a>
</div>
</li>
{% else %}
<li>
<a href="{{ category.href }}">{{ category.name }}</a>
</li>
{% endif %}
{% endfor %}
<li>
<a href="https://yourlink.com">Forum</a>
</li>
</ul>
</div>
</nav>
</div>
{% endif %}
Re: Add an external link to a category (Menu)
Posted: Sat Sep 07, 2019 9:13 am
by letxobnav
don't put data in twig views like that, use the controller menu.php.
add
Code: Select all
$data['categories'][] = array(
'name' => 'NAME_OF_LINK',
'children' => array(),
'column' => 1,
'href' => 'ANY_LINK'
);
before
Code: Select all
return $this->load->view('common/menu', $data);