I am using Zen Cart and currently am building a menu for ecommerce site. I have managed to figure out how to call all the categories but customer only wants the first 4 categories to be shown. There are over 20 categories right now and I only need the first 4 to show on the list. I am not sure the best, and easiest way to do this.
Is there a way to call a list
Example:
<ul>
<li>Menu One</li>
<li>Menu Two
<ul>
<li>Submenu One</li>
<li>Submenu Two</li>
<li>Submenu Three</li>
</ul>
</li>
<li>Menu Three</li>
<li>Menu Four</li>
<li>Menu Five</li>
<li>ect...</li>
</ul>
And then only show
<ul>
<li>Menu One</li>
<li>Menu Two
<ul>
<li>Submenu One</li>
<li>Submenu Two</li>
<li>Submenu Three</li>
</ul>
</li>
<li>Menu Three</li>
<li>Menu Four</li>
</ul>
I am hoping this is a simple solution!
Thanks!
Based on your reply, your query should be:
I don’t know the structure of your db but you can use the above to do a 2 step approach. The first one would be to get the first 4 categories. The second query is to get the subcategories of those 4 categories.
I am not so much in favor of subqueries – I avoid them as much as possible, so that in my view is not a very efficient solution. You could effectively traverse the first query and get the ids from there like so:
The above in my view is much better than the subquery.
HTH
Credits to Lion