opencart mặc định sẽ thêm dropdown button vào main menu khi category có category con. Và không có phần nào chỉnh sửa để bỏ phần dropdown đó đi. Vì vậy cần phải sửa trong file templates của opencart. Comment những phần không cần phải check lại trong vòng lặp for của categories
link file template cho menu:
catalog/view/theme/[template-name]/template/common/header.twig
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
{% for category in categories %} haulpd. disable dropdown main menu {% if category.children %} <li class="menu_oc"> <a href="{{ category.href }}">{{ category.name }} <i class="fa fa-sort-down"></i></a> <div class="dropdown-menus" {% if t1o_menu_main_category_icon_status == 1 and category.thumbbg %}style="background-image: url({{ category.thumbbg }}); padding-right: {{ t1o_menu_main_category_padding_right }}px; padding-bottom: {{ t1o_menu_main_category_padding_bottom }}px;"{% endif %}> {% for children in category.children|batch(category.children|length) %} <ul class="list-unstyled"> {% for child in children %} <li><a href="{{ child.href }}">{{ child.name }}</a> {% if t1o_menu_categories_3_level == 1 %} {% if child.children_level_2 %} <div class="dropdown-menus"> <ul class="list-unstyled"> {% for child2 in child.children_level_2 %} <li><a href="{{ child2.href }}">{{ child2.name }}</a></li> {% endfor %} </ul> </div> {% endif %} {% endif %} </li> {% endfor %} </ul> {% endfor %} <a href="{{ category.href }}" class="see-all dropdown-highlight">{{ text_all }} {{ category.name }}</a> </div> </li> {% else %} <li class="menu_oc"><a href="{{ category.href }}">{{ category.name }}</a></li> {% endif %} |
Để không hiểu thị dropdown nữa, chúng ta comment toàn bộ phần check nếu category.children == true chỉ chừa lại dòng hiển thị category name
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
<!-- Categories OpenCart Style --> {% for category in categories %} {#haulpd. disable dropdown main menu#} {#{% if category.children %}#} {#<a href="{{ category.href }}">{{ category.name }} <i class="fa fa-sort-down"></i></a>#} {#<div class="dropdown-menus" {% if t1o_menu_main_category_icon_status == 1 and category.thumbbg %}style="background-image: url({{ category.thumbbg }}); padding-right: {{ t1o_menu_main_category_padding_right }}px; padding-bottom: {{ t1o_menu_main_category_padding_bottom }}px;"{% endif %}>#} {#{% for children in category.children|batch(category.children|length) %}#} {#<ul class="list-unstyled">#} {#{% for child in children %}#} {#<li><a href="{{ child.href }}">{{ child.name }}</a>#} {#{% if t1o_menu_categories_3_level == 1 %}#} {#{% if child.children_level_2 %}#} {#<div class="dropdown-menus">#} {#<ul class="list-unstyled">#} {#{% for child2 in child.children_level_2 %}#} {#<li><a href="{{ child2.href }}">{{ child2.name }}</a></li>#} {#{% endfor %}#} {#</ul>#} {#</div>#} {#{% endif %}#} {#{% endif %}#} {#</li>#} {#{% endfor %}#} {#</ul>#} {#{% endfor %}#} {#<a href="{{ category.href }}" class="see-all dropdown-highlight">{{ text_all }} {{ category.name }}</a>#} {#</div>#} {#</li>#} {#{% else %}#} <li class="menu_oc"><a href="{{ category.href }}">{{ category.name }}</a></li> {#{% endif %}#} {% endfor %} <!-- Categories OpenCart Style - END --> |