X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Adding calalog to top menu (https://forum.x-cart.com/showthread.php?t=70399)

juancho 11-02-2014 06:19 AM

Adding calalog to top menu
 
Hi

How can I add a Catalog tab in the top menu? this tab should be able to display all categories and subcategories. The same concept as the calatog menu in the sidebar.first, but in the top menu

Thanks

totaltec 11-02-2014 06:21 AM

Re: Adding calalog to top menu
 
Juancho, This is not that hard to code for yourself, but I recommend the module here: https://www.x-cart.com/extensions/addons/horizontal-flyout-categories-menu.html

Save yourself lots of time and trouble!

juancho 11-02-2014 01:58 PM

Re: Adding calalog to top menu
 
Thanks Mike, I wasn't aware of that module.
BTW thanks for all the videos you've uploaded. They are really useful.

juancho 11-03-2014 05:30 AM

Re: Adding calalog to top menu
 
Hi

I bought and installed the module. It does pretty much what I wanted except that now ALL categories have their own tab in the menu. Would it be possible just to have one "Catalog" tab and that all categories and subcategories would be hanging from this principal tab?

Thanks

juancho 11-23-2014 05:35 PM

Re: Adding calalog to top menu
 
Hi I finally got the code to work. I can't guarantee that it will work in all cases but at least it did for me.
Overwrite QSL/HorizontalCategoriesMenu/body.tpl with this code

Code:

{if:isSubtree()}
 <ul class="flyout-menu{if:!isSubtree()} catalog-categories catalog-categories-tree{else:} sublevel{end:}">
 {else:}<li><a href="">Shop</a> <ul class="flyout-menu sublevel">
{end:}
{foreach:getCategories(rootId),idx,_category} 
 <li {displayItemClass(idx,_categoryArraySize,_category):h}>   
<a href="{buildURL(#category#,##,_ARRAY_(#category_id#^_category.getCategoryId()))}" {displayLinkClass(idx,_categoryArraySize,_category):h} title="{_category.getName()}">{_category.getName()}{if:isShowProductNum()&isSubtree()} ({_category.countProducts()}){end:}</a><span class="icon-triangle" IF="isShowTriangle()&_category.hasSubcategories()"></span><widget template="{getBody()}" rootId="{_category.getCategoryId()}" IF="_category.getSubcategoriesCount()&!isRootOnly()}" is_subtree />
<span class="category-icon" IF="isShowCatIcon()&isSubtree()"><widget class="\XLite\View\Image" image="{_category.image}" maxWidth="16" maxHeight="16" /></span>
 </li>
{end:}</li>
  {foreach:getViewList(#topCategories.children#,_ARRAY_(#rootId#^getParam(#rootId#),#is_subtree#^getParam(#is_subtree#))),idx,w}
<li {displayListItemClass(idx,wArraySize,w):h}>{w.display()}</li>
{end:}
</ul>


good luck!

amy2203 11-15-2019 05:20 AM

Re: Adding calalog to top menu
 
I'm trying to do this on 5.3 but the code above doesn't work.

I've added a main "Shop" menu item to the template, and now just need to pupolate the UL with the categories.

I've tried adding this code as copied from /skins/customer/categories/tree/body.twig but it's not working for some reason? I get an Internal Server Error

Code:

<li  class="leaf has-sub"><span>Shop</span>
<ul>
{% for idx, _category in this.getCategories(this.rootId) %}
    <li {{ this.displayItemClass(idx, loop.length, _category)|raw }}>
      <a href="{{ _category.link }}" {{ this.displayLinkClass(idx, loop.length, _category)|raw }}>{{ _category.name }}</a>
      {% if _category.subcategoriesCount %}
        {{ widget(template=this.getBody(), rootId=_category.id, is_subtree='1') }}
      {% endif %}
    </li>
  {% endfor %}
  {% for idx, w in this.getViewList('topCategories.children', {'rootId': this.getParam('rootId'), 'is_subtree': this.getParam('is_subtree')}) %}
    <li {{ this.displayListItemClass(idx, loop.length, w)|raw }}>{{ w.display() }}</li>
  {% endfor %}
</ul>
</li>


welly 11-19-2019 11:08 AM

Re: Adding calalog to top menu
 
I don't think this is quite what you are looking for, but I used the Multilevel Primary Menu module for something like this. I added all of my menu items in a 'logical' order manually.

Up side, I didn't need to code anything, and I can configure any cat name or description I want, including subcategories.

Down side, the menu is not dynamic so each menu item must be configured manually. You may like that, or you may not.

Welly


All times are GMT -8. The time now is 11:06 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.