Post by gunownergear » Fri Jul 04, 2025 10:57 pm

Hello,
Using OC 4.1.0.3
When adding sub-categories, I can get 5 to line up, up and down vertically in the drop down list.
When adding the 6th it starts a new column, and the text overflows the text area ( box )
How do I prevent the drop down list from starting a new column and keep all the sub-categories all lined up vertically ?
I hope this makes sense.
Thanks for your time,
Dan
Last edited by gunownergear on Wed Jul 09, 2025 8:31 pm, edited 1 time in total.

New member

Posts

Joined
Sun Mar 16, 2025 7:06 am

Post by paulfeakins » Mon Jul 07, 2025 7:03 pm

gunownergear wrote:
Fri Jul 04, 2025 10:57 pm
How do I prevent the drop down list from starting a new column and keep all the sub-categories all lined up vertically ?
Are you talking about on the front-end or in the admin?

Perhaps give us a link to your site?

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by gunownergear » Tue Jul 08, 2025 12:42 am

Hi Paul,
Yes on the front end. If I put more than 5 sub-categories in a category, the 6th one will start a new column within the container. The whole sub-category container will double in width, which may be ok and that is how it's supposed to work. I was just wanting to know if there was a setting somewhere where that could be changed without too much trouble. Thought there might be a setting that has a limit of 5, which you could increase the limit.
Unfortunately I consolidated 3 sub-categories into 1 on my website and now it only shows the one column.
Thanks for your time,
Dan

New member

Posts

Joined
Sun Mar 16, 2025 7:06 am

Post by paulfeakins » Tue Jul 08, 2025 6:35 pm

Hi Dan, I think give us a link to your site so we can see what's going on.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by gunownergear » Wed Jul 09, 2025 5:01 am

Hi Paul,
https://gunownergear.com
Hover over the 1st one beside Home "Bags & Cases"
I made 5 test categories and the Range Bags category is supposed to be there .
I suppose the reason it does not overflow is because the name is short?
Thanks for your help,
Dan

New member

Posts

Joined
Sun Mar 16, 2025 7:06 am

Post by by mona » Wed Jul 09, 2025 3:58 pm

In Opencart 3 for a the menu list without columns
in catalog/view/theme/default/template/common/menu.twig
Change

Code: Select all

 <div class="dropdown-inner"> {% for children in category.children|batch(category.children|length / category.column|round(1, 'ceil')) %}
to

Code: Select all

<div class="dropdown-inner"> {% for children in category.children|batch(category.children|length / 1) %}
In Opencart 4 for a the menu list without columns
in catalog/view/theme/default/template/common/menu.twig
Change

Code: Select all

 {% for category in categories %}
              {% if total > 20 %}
                {% set batch = (total / 4)|round(0, 'ceil') %}
                {% set column = 1 %}
              {% else %}
                {% set batch = 100 %}
                {% set column = (total / 5)|round(0, 'ceil') %}
              {% endif %}
to

Code: Select all

{% if total > 20 %}
                {% set batch = (total / 1)|round(0, 'ceil') %}
                {% set column = 1 %}
              {% else %}
                {% set batch = 100 %}
                {% set column = (total / 1)|round(0, 'ceil') %}
              {% endif %}

Or something similar

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by gunownergear » Wed Jul 09, 2025 8:28 pm

YES ! Mona you did it !
I'm using version 4.1.0.3 and my code didn't quite look like that, but just changing the numbers did it.
Path was: catalog/view/template/common/menu.twig
You folks are the greatest !
Thank you,
Dan

UPDATE:
OK Mona,
Initially your code worked, on the first category, but as I hovered over the others, some drop down lists would line up under the category name as they should, but others would line up to the left of the page, or maybe the column grid that they are in, and were horizontal instead of vertical.
I found that if you just change two lines it seems to work as it should.

Code: Select all

              {% if total > 20 %}
                {% set batch = (total / 4)|round(0, 'ceil') %}
                {% set column = 4 %}
              {% else %}
                {% set batch = 10 %}
                {% set column = (total / 10)|round(0, 'ceil') %}
The code example above is the original code except for the bottom two lines.
It seems the percentage number has to match the total number, or it doesn't work.
I just went to 10 on my test, when adding the 11th sub-category it started a new column.
I tested with desktop, but It seems to work with all browser widths.
Again I'm working with version 4.1.0.3
Thanks
Dan

New member

Posts

Joined
Sun Mar 16, 2025 7:06 am

Post by by mona » Wed Jul 09, 2025 10:27 pm

Glad you have it sorted and thank you for coming back with a working solution.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am
Who is online

Users browsing this forum: No registered users and 10 guests