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

Display subcategories that sort by position below each main category?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 01-29-2007, 02:30 PM
 
Smalls Smalls is offline
 

Advanced Member
  
Join Date: Apr 2004
Location: Ontario
Posts: 30
 

Question Display subcategories that sort by position below each main category?

Firstly, the site this applies to is www.xtrememotions.ca. Now, my question is for my main navigation menu, what I'm attempting to do is sort the subcategories of every main category by the position used in X-cart. For example:

Wheel Sports
- scooters
- bicycles
- motorcycles

Water Sports
- water ski's
- surfboards
- tubes

The idea would be that Wheel Sports was pos1, and Water sports was pos2. Within each category respectively, scooters was pos1, bicycles pos2, motorcycles pos3, and waterski's pos1, surfboards pos2, tubes pos3.

What I have so far lists the subcategories beneath every main category, but does not list them by position but rather alphabetically. Anyone have any ideas?

Thanks in advance to anyone who has taken the time to read this or respond!


Here's what I have so far:
{* $Id: categories.tpl,v 1.23 2004/06/24 09:53:29 max Exp $ *}
{capture name=menu}
{if $active_modules.Fancy_Categories ne ""}
{include file="modules/Fancy_Categories/categories.tpl"}
{assign var="fc_cellpadding" value="0"}
{else}
{if $config.General.root_categories eq "Y"}
{foreach from=$categories item=c}
<a href="home.php?cat={$c.categoryid}"><b><font color="#336600" size="3" face="Verdana, Arial, Helvetica, sans-serif">{$c.category}</font></b></a><br />
{foreach from=$allcategories item=cat}
{if $cat.parentid eq $c.categoryid}<font class="CategoriesList"><a href="home.php?cat={$cat.categoryid}" class="VertMenuItems">{$cat.category}</a></font><br />{/if}
{/foreach}
<br />
{/foreach}
{else}
{foreach from=$subcategories item=c key=catid}
<font class="CategoriesList"><a href="home.php?cat={$catid}" class="VertMenuItems">{$c.category}</a></font><br />
{/foreach}
{/if}
{/if}
{/capture}
{ include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_title=$lng.lbl_categories menu_content=$smarty.capture.menu }
__________________
X-Cart Version 4.1.8
Reply With Quote
  #2  
Old 01-29-2007, 03:45 PM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: Display subcategories that sort by position below each main category?

Tons of solutions for this in the Custom Mods forum...search for 'subcategory' or 'category'
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #3  
Old 01-30-2007, 05:32 AM
 
Smalls Smalls is offline
 

Advanced Member
  
Join Date: Apr 2004
Location: Ontario
Posts: 30
 

Default Re: Display subcategories that sort by position below each main category?

not to be rude but I dont think you quite read the post entirely through, Im looking for a solution that also allows you to select the positioning of each menu element, any solutions I could find were similar to the one I posted which does not allow specific ordering or positioning of each menu element.

If perhaps there is a solution that you know of, could you be so kind as to give me a specific link? I've spent hours scouring the forum and could not find the solution you mention, thanks in advance.
__________________
X-Cart Version 4.1.8
Reply With Quote
  #4  
Old 01-30-2007, 06:04 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: Display subcategories that sort by position below each main category?

I did read the post, and I understand that you have the subcategories in place already and just want to change the order. The mods in the Custom Mods forum discuss this as well, and you will see that you need to open up include/categories.php and make some adjustments to the ORDER BY variables. By default, they are alphabetical, so you would need to change them to POS. I don't have the specifics in front of me, but look for instances like this:

ORDER BY $sql_tbl[categories].order_by, $sql_tbl[categories].category";

That would default to order by first, alphabetical second. Make sure order_by is first for all of the different options in that file.

Also, please keep all discussion to the forum itself. PMs to moderators should only be used if there is a problem with the forum. Thank you
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #5  
Old 01-30-2007, 06:30 AM
 
Smalls Smalls is offline
 

Advanced Member
  
Join Date: Apr 2004
Location: Ontario
Posts: 30
 

Default Re: Display subcategories that sort by position below each main category?

thanks balinor, appreciate it. I think this may lead to something, ill look into it and post anything I come up with
__________________
X-Cart Version 4.1.8
Reply With Quote
  #6  
Old 02-21-2007, 10:09 AM
  chris2002's Avatar 
chris2002 chris2002 is offline
 

Advanced Member
  
Join Date: Mar 2006
Location: French Polynesia
Posts: 30
 

Default Re: Display subcategories that sort by position below each main category?

Solution for 4.1.6

in incude/categorie.php

Search for this in your code :
#
# Override subcategory_count for Admin area
#
if(!empty($subcategories) && ($current_area == 'A' || ($current_area == 'P' && $active_modules['Simple_Mode']))) {
$product_counts = func_query_hash("SELECT categoryid, COUNT(*) FROM $sql_tbl[products_categories] WHERE categoryid IN ('".implode("','", array_keys($subcategories))."') GROUP BY categoryid", "categoryid", false, true);
foreach($subcategories as $k => $v) {
$subcategories[$k]['subcategory_count'] = func_query_first_cell("SELECT COUNT(subcat.categoryid) as subc FROM $sql_tbl[categories] USE INDEX (PRIMARY) LEFT JOIN $sql_tbl[categories] as subcat ON subcat.categoryid_path LIKE CONCAT($sql_tbl[categories].categoryid_path, '/%') WHERE $sql_tbl[categories].categoryid = '$k' GROUP BY $sql_tbl[categories].categoryid");
$subcategories[$k]['product_count_global'] = $subcategories[$k]['product_count'];
$subcategories[$k]['product_count'] = isset($product_counts[$k]) ? intval($product_counts[$k]) : 0;
}
}



then add this just below the line :


//Subcategories in menu
function func_getallsubcat()
{
$raj =func_get_categories_list("", true, "all");
$raj1=$raj['all_categories'];
$ll=array();
foreach ($raj1 as $k=>$val)
{
if($val['parentid']!="0")
{
$ll[$val['parentid']][]=$val;
}
}
return $ll;
}
$smarty->assign("allsubcategories", func_getallsubcat());
//Subcategorie in menu - end
__________________
Chris
----------------------------------------
X-Cart Gold 4.1.xx / 4.2.xx
Need some Help in french
Webdesign or else.
----------------------------------------
Reply With Quote
  #7  
Old 04-27-2007, 12:36 PM
 
awasson awasson is offline
 

Newbie
  
Join Date: Mar 2005
Location: Vancouver, BC Canada
Posts: 8
 

Default Re: Display subcategories that sort by position below each main category?

Smalls: Did you ever figure this out?

I also modified my templates and categories to do the drop down and keep the subcats open while browsing within. I detailed the method HERE.

I looked at what balinor suggested and it makes sense. There are 3 references to 'ORDER BY' however 2 of them are order by $sql_tbl[categories].order_by first and changing the other to match makes no difference in my case.

I'll keep plugging away myself and post the results but if you have any ideas, I'm all ears.

Thanks,
Andrew
__________________
X-Cart Gold Version 4.15
PHP 5.16 / MySQL 5.022
Apache 2.2.3 / Linux (Fedora Core 6)
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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 07:18 AM.

   

 
X-Cart forums © 2001-2020