Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8620025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:28:54+00:00 2026-06-12T06:28:54+00:00

I am using Zen Cart and currently am building a menu for ecommerce site.

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:28:56+00:00Added an answer on June 12, 2026 at 6:28 am

    Based on your reply, your query should be:

    // Categories
    $lid = (int) $_SESSION['languages_id']; 
    $sql = "SELECT c.categories_id, cd.categories_name, c.parent_id "
         . "FROM " . TABLE_CATEGORIES . " c, " 
         . TABLE_CATEGORIES_DESCRIPTION . " cd "
         . "WHERE c.categories_id = cd.categories_id and c.categories_status = 1 " 
         . "AND cd.language_id = '{$lid}' "
         . "ORDER BY c.parent_id, c.sort_order, cd.categories_name "
         . "LIMIT 4"; 
    $categories = $db->Execute($sql);
    
    // Subcategories of the above
    $lid = (int) $_SESSION['languages_id']; 
    $sql = "SELECT c.categories_id, cd.categories_name, c.parent_id "
         . "FROM " . TABLE_CATEGORIES . " c, " 
         . TABLE_CATEGORIES_DESCRIPTION . " cd "
         . "WHERE c.categories_id IN ("
         .     "SELECT c.categories_id "
         .     "FROM " . TABLE_CATEGORIES . " c, " 
         .     TABLE_CATEGORIES_DESCRIPTION . " cd "
         .     "WHERE c.categories_id = cd.categories_id and c.categories_status = 1 " 
         .     "AND cd.language_id = '{$lid}' "
         .     "ORDER BY c.parent_id, c.sort_order, cd.categories_name "
         .     "LIMIT 4" 
         . "); 
    $subcategories = $db->Execute($sql);
    

    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:

    // Categories
    $lid = (int) $_SESSION['languages_id']; 
    $sql = "SELECT c.categories_id, cd.categories_name, c.parent_id "
         . "FROM " . TABLE_CATEGORIES . " c, " 
         . TABLE_CATEGORIES_DESCRIPTION . " cd "
         . "WHERE c.categories_id = cd.categories_id and c.categories_status = 1 " 
         . "AND cd.language_id = '{$lid}' "
         . "ORDER BY c.parent_id, c.sort_order, cd.categories_name "
         . "LIMIT 4"; 
    $categories = $db->Execute($sql);
    
    // Loop through the $categories and get the ids
    $category_ids = array();
    foreach ($categories as $category)
    {
        $category_ids[] = $caregory->categories_id;
    }
    // Subcategories of the above
    $lid = (int) $_SESSION['languages_id']; 
    $sql = "SELECT c.categories_id, cd.categories_name, c.parent_id "
         . "FROM " . TABLE_CATEGORIES . " c, " 
         . TABLE_CATEGORIES_DESCRIPTION . " cd "
         . "WHERE c.categories_id IN (" . implode(",", $category_ids) . ")";
    $subcategories = $db->Execute($sql);
    

    The above in my view is much better than the subquery.

    HTH

    Credits to Lion

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script that logs page visits on my zen-cart site at the
I have started a zen cart custom theme using the default theme. Now I
I am using Drupal 6.x with Zen theme. Currently, the following 3 user functions
I am working on something that uses Zen Cart. Changing the site from Zen
I am working with a pre-existing zen-cart site has been worked on over the
I have a big website build in drupal and i am using zen TSI
When using a Zen sub-theme in Drupal, I get the following warnings. How can
Using the Redis info command, I am able to get all the stats of
So basically i have a js file which looks like: var player = $("#zen
I am currently trying to create a Drupal theme as a Zen subtheme, by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.