Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Adding a second 'categories' section

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #11  
Old 06-11-2008, 06:06 AM
 
mike@tatechnology.net mike@tatechnology.net is offline
 

Senior Member
  
Join Date: May 2006
Posts: 132
 

Default Re: Adding a second 'categories' section

Quote:
Originally Posted by Duramax 6.6L
Thank you balinor, You are always a help here.

There was a post on here on how to add a second box. Do you by chance know where it is, I am searching and can not find.


http://forum.x-cart.com/showthread.php?t=19871&highlight=custom+menu

http://forum.x-cart.com/showthread.php?t=24054&highlight=add+menu


I have these saved in my favorite
__________________
TA Technologies, Inc.
~Implementing Creative Point of Sale Solutions~
http://www.rmspos.net
X-Cart 4.1.10
Reply With Quote
  #12  
Old 09-07-2009, 05:51 PM
 
Richardl Richardl is offline
 

Advanced Member
  
Join Date: May 2009
Location: Australia
Posts: 42
 

Default Re: Adding a second 'categories' section

The code has a bug when doing a search, all categories go under menu 1 leaving menu 2 blank!

I've been trying to figure this out for a while, can somebody help?
__________________
Version 4.2.1
Reply With Quote
  #13  
Old 02-10-2010, 09:15 AM
 
bionuts bionuts is online now
 

Advanced Member
  
Join Date: Oct 2008
Location: At my desk, probably scratching my head over an X Cart problem....
Posts: 91
 

Default Re: Adding a second 'categories' section

I've experienced the problem of a second menu not displaying on search result pages whilst trying to get a second category menu to appear in my 4.3 installation. I managed to solve the problem, so thought I'd share what I did in case others might find it useful. Please note, though, that I have only tried this on 4.3 and do not know if it will be backwards compatible. In addition, I'm not a programmer, so before you try my solution make sure you've got a working back up of all your files - better safe than sorry.

First of all, I copied customer/categories.tpl and created a new file called customer/categories_type.tpl. In each file I changed the {foreach} loop to be either (code I've added is highlighted):

Code:
{foreach from=$categories_menu_list item=c name=categories} {if $c.order_by lt 500} <li{interline name=categories}><a href="home.php?cat={$c.categoryid}" title="{$c.category|escape}">{$c.category}</a></li> {/if} {/foreach}
or

Code:
{foreach from=$categories_menu_list item=c name=categories} {if $c.order_by gt 501} <li{interline name=categories}><a href="home.php?cat={$c.categoryid}" title="{$c.category|escape}">{$c.category}</a></li> {/if} {/foreach}
depending on which file it was in. I then added:

Code:
{include file="customer/categories_type.tpl"}

to my customer/home.tpl in the right place for where I wanted the second menu to display. Lastly, I created a new variable in my language file so that I could give the new menu a different name. With the category position order sorted out, this displays my two category menus exactly where I want them, and with the right categories in each one.

Except on the search results page, that is. For some reason, the search results page (and the advanced search page) ignores the foregoing code and displays all of the categories in the original menu - even the ones that should be in the second menu. The second menu is empty, although the heading is still displayed.

From experimenting, it appears that the search results will ignore the {if} statement added to the categories.tpl and categories_type.tpl files if you use $c.order_by to define it. The only way I can get it to work is to use $c.categoryid instead. This is the number that is assigned to the category upon creation, and which you can only see if you look at your SQL database in something like PHPMyAdmin.

Looking at my database, the first category has $c.categoryid 10 and then all the others are numbered sequentially from there - with gaps for some that have been deleted. The $c.categoryid is completely unrelated to the position order that you assign to categories in your X Cart admin.

So, armed with the necessary $c.categoryid information, I've changed my {foreach} loops to be:

Code:
{foreach from=$categories_menu_list item=c name=categories} {if $c.categoryid lt 32 or $c.categoryid eq 50 or $c.categoryid eq 51} <li{interline name=categories}><a href="home.php?cat={$c.categoryid}" title="{$c.category|escape}">{$c.category}</a></li> {/if} {/foreach}
which displays categories 10 to 31, 50 and 51 in the first menu and

Code:
{foreach from=$categories_menu_list item=c name=categories} {if $c.categoryid gte 32 and $c.categoryid ne 50 and $c.categoryid ne 51} <li{interline name=categories}><a href="home.php?cat={$c.categoryid}" title="{$c.category|escape}">{$c.category}</a></li> {/if} {/foreach}
which displays categories 32 onwards (except for 50 and 51) in the second menu.

Done this way, the correct categories show up in the correct menus and are visible on every page - including search results pages.

It's more of a fiddle to do it this way, as there is no reference to the $c.categoryid in the X Cart admin, and when you add new categories their $c.categoryid will always be the next sequential number - which makes it less easy to assign them to the correct menu, without changing your {if} statements. But it does display as needed and doesn't seem to mess anything else up.
__________________
Currently transitioning to X-Cart 5.4.x.x. Oh the joy
Reply With Quote
  #14  
Old 04-05-2010, 11:10 PM
 
drudden drudden is offline
 

Advanced Member
  
Join Date: Dec 2005
Posts: 66
 

Default Re: Adding a second 'categories' section

Quote:
Originally Posted by bionuts
From experimenting, it appears that the search results will ignore the {if} statement added to the categories.tpl and categories_type.tpl files if you use $c.order_by to define it. The only way I can get it to work is to use $c.categoryid instead. This is the number that is assigned to the category upon creation, and which you can only see if you look at your SQL database in something like PHPMyAdmin.

Thank you for posting this. I was having the same issue and your input helped me resolve my issue.

I just wanted to add that you can get the category id without the hassle of going into the database. The id's for categories, products, manufacturers, etc. are actually used as parameters in the url's that you click to edit them. Simply login to your admin and hover over any category link and you can get your id's.
__________________
Thanks,

Dan

X-Cart Version 4.3.1
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

   

 
X-Cart forums © 2001-2020