![]() |
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 } |
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'
|
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. |
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 :) |
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
|
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 |
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 |
All times are GMT -8. The time now is 11:06 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.