OpenCart header navigation (three level list)

Recently, I had a bite of Open Cart to build a new website for a client. Its still in development, but the outcome seems promising. I have to say, as much as I had heard about Open Cart, it really is a great piece of web application. My journey with shopping carts have been restless. I have had tough times with OSCommerce, played enough with ZenCart, dealt with the terrible NiagaKit, and even adventured on my favorite enterprise level Magento. While Magento is still the best for me, Open Cart is just the next one for me. Reason why Open Cart is behind Magento is only because of the number of features that it has. For my carts that need enterprise love, I use Magento for them. For all others, Open Cart is my choice now.

So, I was modding a custom made theme for a client who will be selling products on his very own Open Cart. I realized that it did not have header navigation. Actually, it did not have category list tables. The current category.tpl template file calls the categories available for the viewed page only. While Open Cart will be implementing listed categories in the next version, my client couldn’t wait. So I had to do what I had to do.

Google! Thats where I found Craig Murrays neat category list code. The code works, but apparently he limited it to two level navigation only. The parent and a child. I think for a shopping cart, the maximum navigation levels should be three rather than two. In my clients case who was selling hijabs, she needed three level navigation. eg: hijab -> the type of hijab -> the material. So I took Craig’s code and modified it into a three-level navigation. The generated list item will look something like this:

   <li>First Level</li>
   <li>First Level
         <li>Second Level</li>
         <li>Second Level
               <li>Third Level</li>
               <li>Third Level</li>
         <li>Second Level</li>
   <li>First Level</li>

Once you have this list, you can give it some CSS touch and use Superfish or most other jQuery scripts to add the animation effect for added functionality. Now here is the PHP code to generate this list (along with descriptions on what each line does):

$results = $this->model_catalog_category->getCategories();  									// get the categories
if ($results) {$output = '<ul class="you-can-define-a-class-here-for-your-javascripts">';}  									// if there are categories available, start off with the unordered list tag
foreach ($results as $result) {																	// for each result
	$output .= '<li>';																			// put a list item tag
	$new_path = $result['category_id'];															// get the id of this category
	$unrewritten = HTTP_SERVER.'index.php?route=product/category&path=' . $new_path;			// if the seo url is disabled, this will be the path
	$rewritten = $this->model_tool_seo_url->rewrite($unrewritten);								// otherwise, it will be this one
	$output .= '<a href="' . $rewritten . '">' . $result['name'] . '</a>';						// finally, generate the category name and wrap its link
	$sub_results = $this->model_catalog_category->getCategories($new_path);						// if this result has a sub-list, get the set of new categories
	if ($sub_results) {$output .= '<ul>';}														// if this is a subresult, start off with an unordered list tag
	foreach ($sub_results as $sub_result) {														// for each of this subresult item
		$output .= '<li>';																		// put a list item tag
		$new_sub_path = $sub_result['category_id'];												// get its category
		$sub_unrewritten = $unrewritten.'_'. $new_sub_path;										// if the seo is disabled, this will be the path
		$sub_rewritten = $this->model_tool_seo_url->rewrite($sub_unrewritten);					// otherwise, it will be this one
		$output .= '<a href="' . $sub_rewritten . '">' . $sub_result['name'] . '</a>';			// now, generate the category name and wrap its link
		$third_sub_results = $this->model_catalog_category->getCategories($new_sub_path);		// if this result has a sub-list, get the set of new categories
		if ($third_sub_results) {$output .= '<ul>';}											// if this is a subresult, start off with an unordered list tag
		foreach ($third_sub_results as $third_sub_result) {										// for each of this third level item
			$output .= '<li>';																	// give it an opening list tag
			$third_sub_path = $third_sub_result['category_id'];									// get its category
			$third_sub_unrewritten = $sub_unrewritten.'_'.$third_sub_path;						// if seo is disabled, this is the path
			$third_sub_rewritten = $this->model_tool_seo_url->rewrite($third_sub_unrewritten);	// if its enabled, this will be the path
			$output .= '<a href="'.$third_sub_rewritten.'">'.$third_sub_result['name'].'</a>';	// call the category name and wrap with its link
			$output .= '</li>';																	// now close this list item
		if ($third_sub_results) {$output .= '</ul>';}											// if this was the third list, clost the list
			$output .= '</li>';																	// then or otherwise, close the second level list tag
	if ($sub_results) {$output .= '</ul>';}														// if all sub results have been listed, close the second level
		$output .= '</li>';																		// then or otherwise close first list parent
if ($results) {$output .= '</ul>';}																// then close the first level list table
echo $output; 																					// now produce the results

I hope that helps for some of you guys looking forward to add this to your Open Carts. Open Source..ftw!


  1. android porn app
    #1 written by android porn app  (5 years ago)

    ATTENTION -FOR ADULTS ONLY!!!Just sharing this great new app with pure porn, NO
    ads, NO bullshit- Dirty Monika Android App.
    Download it for free with the link here. Enjoy responsibly

  2. how to make extra money
    #2 written by how to make extra money  (5 years ago)

    If you are a newbie to the world of internet marketing, or affiliate marketing, you have to be careful of your approach,
    as to what direction you choose to take to begin your marketing campaigns.
    However, once you choose to do this, make sure that
    you have the right content and necessary applications to
    avoid wasting the time of the user. Of course
    as a beginner it is better to start with the free methods to promote your products.

  3. homepage
    #3 written by homepage (5 years ago)

    Hi! I know this is kinda off topic but I was wondering which bog platform are youu using for this website?
    I’m getting fed up of WordPress because I’ve had problems
    with hackers andd I’m looking at alternatives foor another platform.
    I would be awesome if you could point me in the direction of a
    good platform.

  4. เช่าชุดราตรี
    #4 written by เช่าชุดราตรี  (5 years ago)

    I know this if off topic but I’m looking into starting
    my own blog and was curious what all is required to get setup?
    I’m assuming having a blog like yours would cost a pretty penny?

    I’m not very web savvy so I’m not 100% sure. Any suggestions or advice
    would be greatly appreciated. Kudos

    my web blog เช่าชุดราตรี

  5. 401K contribution limits
    #5 written by 401K contribution limits (5 years ago)

    What’s up to every body, it’s myy ffirst pay a quick visit of this weblog; this blog consists of amazing and really fine stuff foor readers.

  6. plus size womens cotton underwear
    #6 written by plus size womens cotton underwear  (5 years ago)

    Know the Precise Lingerie Size of your Girlfriend
    – Don’t neglect that, her apparel measurement and lingerie measurement is entirely distinct.
    So, it is better to focus your shopping based on branded items that are high
    quality and enhance your figure. Red-heads impress with earth tones and other Earth-inspired colors, like greens and blues.

    my web blog … plus size womens cotton underwear

  7. free minecraft server hosting
    #7 written by free minecraft server hosting (5 years ago)

    I’m gone to convey my little brother, that he should also visit this
    web site on regular basis to obtain updated from newest gossip.

    Have a look at my blog: free minecraft server hosting

  8. shower radio
    #8 written by shower radio  (5 years ago)

    What i don’t realize is if truth be told how you’re now not actually a lot
    more smartly-appreciated than you might be now. You are so intelligent.
    You understand therefore significantly in terms of this matter, made me personally believe it from
    numerous varied angles. Its like men and women don’t
    seem to be fascinated until it’s something to accomplish with
    Girl gaga! Your personal stuffs excellent. At all times handle it up!

    Feel free to visit my web-site :: shower radio

    #9 written by  (5 years ago)

    What they did not experience wdre the typical side effects oof cambogia o vietnam HCAGarcinia is possibly safe for most people theree
    are no dangerous side effects. Some of these benefits are the
    following: Fat-blocker, Appetite suppressant to help control over eating,
    increase serotonin which helps in fighting depression as well ass tthe effectiveness.
    cambogia o vietnam Cambogia has been uses in Ayurvediuc medicine for

    My web-site

  10. tas laptop wanita
    #10 written by tas laptop wanita  (5 years ago)

    Howdy just wanted to give you a quick heads up and let you know a few of
    the images aren’t loading correctly. I’m not sure why but I think its a linking issue.

    I’ve tried it in two different web browsers and both show the same results.

  11. top 10 diet pills of 2013
    #11 written by top 10 diet pills of 2013 (5 years ago)

    This is also a rare and protected plant, and meal supplements are fat but still need step by step help?
    Once you decide to get a variety of fats to lose weight is to consume as many
    otc diet pills that really work vegetables as you have this goal.
    Crash dieting may also suggest measures on how much
    to be the most common is anal otc diet pills that really work
    leakage and loose stools.

  12. top nike bot
    #12 written by top nike bot  (5 years ago)

    hey there and thank you for your information – I have certainly picked
    up anything new from right here. I did however
    expertise several technical points using this website, since
    I experienced to reload the website many times previous to I could get it to
    load correctly. I had been wondering if your hosting is OK?
    Not that I’m complaining, but slow loading instances times will often affect your placement in google and can damage your
    high quality score if ads and marketing with Adwords.

    Well I’m adding this RSS to my e-mail and could look out for
    much more of your respective interesting content.
    Make sure you update this again very soon.

  13. Phuc
    #13 written by Phuc (5 years ago)

    you just change:

  14. wedding apps
    #14 written by wedding apps  (5 years ago)

    Hi there, all the time i used to check webpage posts here in the early hours in the dawn, because i enjoy to find out more
    and more.

  15. webpage
    #15 written by webpage  (5 years ago)

    Hello There. I found your blog using msn. That is a
    really neatly written article. I’ll make sure to bookmark it and come back to
    read extra of your useful info. Thank you for
    the post. I will certainly comeback.

  16. Riad Marrakech Marriage
    #16 written by Riad Marrakech Marriage (5 years ago)

    Mariah was previously linked to becoming a travel agent and medical clinic
    manager. You don’t have to. Insurance provides a way to make revenue off of the actions of
    their citizens. There is a precision and a saturation to the country.
    I had the pleasure of this volume for true-crime readers.
    Hazy, just out of reach, but the riad marrakech mandaline gardens not all,
    sub-Saharans in Morocco are likely to be part of the human body can help
    with costs for loss of enjoyment.

    Take a look at my web blog … Riad Marrakech Marriage


    You can use one or more of these per level so if you only need
    to clear one more jelly and are completely frustrated with a level that is an option.
    Blu-ray Deal of the Week: RVBX: Ten Years of Red
    vs. The latest e – Book guide sells at the cost of many of those extras on the new game, yet provides helpful tips and tricks for beating tougher levels, and extra resource links for more help.

    Here is my web-site; Bubble Witch Saga 2 Hack (

  18. cordyceps
    #18 written by cordyceps  (5 years ago)

    Excellent write-up. I absolutely love this site.

  19. marcenarias em sp
    #19 written by marcenarias em sp  (5 years ago)

    Hmm it appears like your blog ate my first comment (it
    was super long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your
    blog. I as well am an aspiring blog blogger but I’m still new to
    the whole thing. Do you have any points for first-time blog writers?
    I’d really appreciate it.

    #20 written by (5 years ago)

    Hurrah! After all I got a website from where I know how to in fact obtain valuable data
    regarding my study and knowledge.

  21. machines for pizza dough
    #21 written by machines for pizza dough (5 years ago)

    Hey There. I found your blog using msn. This is
    a very well written article. I will be sure to bookmark
    it and return to read more of your useful information. Thanks
    for the post. I will certainly comeback.

    Feel free to surf to my web site: machines for pizza dough

  22. index
    #22 written by index  (5 years ago)

    Great article. I’m facing a few of these issues
    as well..

  23. cellulite news 2013
    #23 written by cellulite news 2013 (5 years ago)

    Have you ever considered about including a little bit more than just your articles?
    I mean, what you say is valuable and all. Nevertheless think about if you
    added some great graphics or videos to give your posts
    more, “pop”! Your content is excellent but with pics and video clips, this website could certainly be one of the most
    beneficial in its field. Superb blog!

    Here is my homepage – cellulite news 2013

  24. Laurene
    #24 written by Laurene (5 years ago)

    Good post however I was wondering if you could write a litte
    more on this topic? I’d be very thankful if you could elaborate
    a little bit more. Kudos!

    Feel free to visit my site … will there be a cure for herpes in the future (Laurene)

    #25 written by  (5 years ago)

    I like the valuable information you supply on your articles.
    I’ll bookmark your blog and test once more right here frequently.
    I’m quite certain I’ll learn many new stuff proper right here!
    Best of luck for the following!

  26. Cricket Revolution steam key generator download

    excellent submit, very informative. I wonder why the other experts of this sector don’t realize this.

    You should proceed your writing. I am confident, you have a great readers’ base already!

  27. Bruno
    #27 written by Bruno  (5 years ago)

    The Bitcoin boom has given rise to a whole new class of tech-savvy
    capitalists; comprised of enthusiasts, speculators, and entrepreneurs
    – many of whom now find themselves in a much higher tax bracket.
    One incentive for doing so is the low transaction fees involved.
    Make sure you download and install the dependencies before you install the freeware.
    For example, the effect of a solar flare on the complex
    software that manages the communication satellite systems could be derived very quickly.

  28. weddings in donegal
    #28 written by weddings in donegal  (5 years ago)

    This way the perform does not appear as a lot and as demanding for you.

    Modern systems have been actively playing an additional and
    additional essential aspect in the lives of folks all over the earth, and not just with e-mail and business choices.
    Relationship counseling will help couples realize and resolve conflicts and boost their relationships.

    my web-site … weddings in donegal

  29. voyage vietnam
    #29 written by voyage vietnam  (5 years ago)

    According to the USPS Post Office, there is no United
    States mail delivery on Martin Luther King Jr. Well, besides the fun and enjoyment
    there is another factor which people would love in the
    Singapore Holidays Well these are the historical places.

    It is considered a romantic gateway for honeymooners who
    visit this place to begin blissful new inning of their married life.

  30. diet for muscle building
    #30 written by diet for muscle building (5 years ago)

    Great information. Lucky me I found your blog by chance (stumbleupon).
    I’ve saved it for later!

    my webpage – diet for muscle building

  31. best anti age cream
    #31 written by best anti age cream (5 years ago)

    Article writing is also a excitement, if you know afterward
    you can write or else it is complex to write.

    my website :: best anti age cream

  32. Natural Skin Toner Recipe
    #32 written by Natural Skin Toner Recipe (5 years ago)

    Hello there! Do you know if they make any plugins to protect against hackers?
    I’m kinda paranoid about losing everything I’ve worked hard on. Any suggestions?

    my webpage … Natural Skin Toner Recipe

  33. website
    #33 written by website  (5 years ago)

    I got thbis web site from my pal who shared with me about this web page and now this time I
    am browsing this web sjte and reading very informative content
    at this time.

  34. lifecell skin care reviews
    #34 written by lifecell skin care reviews (5 years ago)

    Admiring the hard work you put into your website and detailed
    information you present. It’s awesome to come across a blog every once in a while
    that isn’t the same out of date rehashed material.
    Fantastic read! I’ve bookmarked your site and I’m including
    your RSS feeds to my Google account.

    My webpage … lifecell skin care reviews


    Great beat ! I would like to apprentice while you amend your
    web site, how could i subscribe for a blog site?

    The account aided me a acceptable deal. I had been tiny bit acquainted of this
    your broadcast provided bright clear concept

  36. Gregorio
    #36 written by Gregorio  (5 years ago)

    If you wish for to grow your familiarity just keep visiting this web site and
    be updated with the latest news update posted here.

  37. Mariam
    #37 written by Mariam  (5 years ago)

    Thank you for the good writeup. It if truth be told was
    a amusement account it. Glance complicated to more delivered agreeable from you!
    By the way, how can we communicate?

    My homepage – natural home remedies for herpes simplex; Mariam,

  38. where to buy premium pure forskolin
    #38 written by where to buy premium pure forskolin  (5 years ago)

    It’s in fact very complicated in this busy life to listen news
    on Television, therefore I only use world wide web for that reason, and take the most up-to-date news.

    Feel free to visit my web page … where to buy premium pure forskolin

  39. Suits For Women
    #40 written by Suits For Women (5 years ago)

    When I initially commented I clicked the “Notify me when new comments are added” checkbox and now each
    time a comment is added I get several emails with the same comment.
    Is there any way you can remove people from that service?

    Thanks a lot!

  40. wedding dress
    #41 written by wedding dress  (4 years ago)

    I happen to see a shop where sells ball gown wedding dresses and.
    Outfits with this neckline are ideal for you if you have a petite
    body. From putting together the budget and guest list to
    choosing flower bouquets and bridesmaid dresses, it can be a dizzying amount
    of tasks to take on at any given time.

  41. data recovery
    #42 written by data recovery  (4 years ago)

    I do consider all the concepts you have introduced in your post.
    They are very convincing and will certainly work.
    Nonetheless, the posts are very brief for novices. May just you please
    lengthen them a little from next time? Thanks for the post.

  42. игры скачать на мобильный

    Спасибо, У меня только были в поисках Информация примерно
    для давно и Твое есть лучшим У меня есть
    обнаружил сих пор. Однако,
    касающийся нижней линии? Вы уверены, что о исходного?

  43. how?to?increase?your?app?traffic
    #44 written by how?to?increase?your?app?traffic (3 years ago)

    Get more app downloads by opti app store game ranking mizing your app store listing using these tips and best practices,app store game ranking. We are offering you the best app store optimization to help you achieve the success of app marketing.

  44. battle camp gold cheat
    #45 written by battle camp gold cheat (3 years ago)

    Try the newest Marvel Contes dominations crowns cheat t of Champions online cheats. Be better than your friends,dominations crowns cheat, and gain advantage easily! Hack Marvel Contest of Champions.Buy Marvel Contest of Champions unlimited units!

  45. Syked
    #46 written by Syked  (3 years ago)

    I am new to web developing so I am gonna ask a stupid question but what is the directory of the file that needs to be modified and where do i insert the code at?

  46. Neha kitey
    #47 written by Neha kitey  (3 years ago)

    hello sir,
    please tell me where i have to put this code for generating three level menu
    please help me sir i am beginer
    thank you

  47. houston dog obedience training
    #48 written by houston dog obedience training  (3 years ago)

    Thank you for this. You always have some great posts.
    I shared this on Facebook and my followers loved it.
    Keep the the great work!

  48. hybrid tend
    #49 written by hybrid tend  (2 years ago)

    Some truly interesting details you have written.Aided me a
    lot, just what I was looking for :D.

  49. app store aso
    #50 written by app store aso (2 years ago)

    How to select the right keywords for your new-developed apps? Vis aso app store optimization it to find a series of free keywords optimization tools to help you grasp app store top charts and keywords searches trendings. At the same time,aso app store optimization, the exerienced team is ready for serving app

  50. You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  51. Comment Feed for this Post
Go to Top