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

ALWAYS display first level subcats beneath root cats

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #21  
Old 05-10-2006, 03:34 PM
 
krur krur is offline
 

Newbie
  
Join Date: May 2006
Location: Milan - Italy
Posts: 6
 

Default

i did try to make it work under 4.1 but no result..
i'm still too young with xcart and smarty.. anybody fixed it? pleease
__________________
Stefano Cecere - krur.com
X-cart 4.1.1 Gold on Linux
Reply With Quote
  #22  
Old 05-11-2006, 12:19 AM
  chamberinternet's Avatar 
chamberinternet chamberinternet is offline
 

X-Wizard
  
Join Date: Sep 2005
Location: Lancashire, UK
Posts: 1,470
 

Default

Hello ..

I did manage to get it working (with some help from the guys @ XCart Support)

This is how it's done:

Modify the "<xcart-dir>/include/categories.php" file:

1) find the following line (it is 290th in X-Cart v4.1.0 by default)

if (($current_area == "C" && defined("GET_ALL_CATEGORIES")) || defined('MANAGE_CATEGORIES')) {

2) replace it with the next one

if (($current_area == "C") || defined('MANAGE_CATEGORIES')) {


Then edit categories.tpl replace with the following code after {if $config.General.root_categories eq "Y"}


{foreach from=$categories item=c}
<font class="CategoriesList">{$c.category}</font>
<ul>
{foreach from=$allcategories item=cat}
{if $cat.parentid eq $c.categoryid}[*]<font class="CategoriesList">{$cat.category}</font>
{/if}
{/foreach}[/list]{/foreach}

Hope this helps ...

Regards

Shafiq :sK
__________________
Developing in 4.7.x now (Dipping into v5 - Slowly!)
Have used 4.1.x, 4.2.x, 4.4.x, 4.5.x, 4.6.x & 4.7.x
Multiple Instances of X-Cart
MySQL 5.6.37
CentOS 7.4


Chamber Internet
- Lancashire, United Kingdom
http://www.chamberelancs.co.uk
Reply With Quote
  #23  
Old 05-18-2006, 03:11 AM
 
sank sank is offline
 

Advanced Member
  
Join Date: May 2006
Location: West Midlands
Posts: 34
 

Default

Quote:
Originally Posted by bluski
Thanks for the mod. Just what I was seeking, and there were only old posts for older versions. So thanks, ExoZed!!!

I modified your code so that all main categories will show on home page and when you click on a main category, only the subcats for that cat will show (and stay shown!) while the main categories will always show.

I'm new to PHP and Smarty, so someone please check my code.


Code:
{* $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="`$fancycategories_config.modules_path`/fancy_categories.tpl"} {else} {if $config.General.root_categories eq "Y"} {section name=cat_num loop=$categories} <FONT class="CategoriesList">{$categories[cat_num].category}</FONT> {if $cat eq $categories[cat_num].categoryid || $current_category.parentid eq $categories[cat_num].categoryid} {section name=subcat loop=$allcategories} {if $allcategories[subcat].parentid eq $categories[cat_num].categoryid} {$allcategories[subcat].category} {/if} {/section} {/if} {/section} {else} {section name=cat_num loop=$subcategories} <FONT class="CategoriesList">{$subcategories[cat_num].category}</FONT> {/section} {/if} {/if} {/capture} { include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_content=$smarty.capture.menu }

I've tried using this in Version 4.0.18.

The links work and i get the right amount for each category. My problem is, instead of displaying the sub-category name, it just displays "Array" over and over.

Any ideas anyone?

Thanks

Dave
__________________
X-Cart Gold Version 4.1.9

www.fredsbedshed.co.uk
Reply With Quote
  #24  
Old 10-03-2006, 10:33 AM
 
Jeremy.Freeman Jeremy.Freeman is offline
 

Advanced Member
  
Join Date: Mar 2005
Posts: 79
 

Default Re: ALWAYS display first level subcats beneath root cats

This works great on 4.1.3! However, the subcategories are not displaying in the order they are specified to order by (based on pos).. any idea how to do that?

Quote:
Originally Posted by chamberinternet
Hello ..

I did manage to get it working (with some help from the guys @ XCart Support)

This is how it's done:

Modify the "<xcart-dir>/include/categories.php" file:

1) find the following line (it is 290th in X-Cart v4.1.0 by default)

if (($current_area == "C" && defined("GET_ALL_CATEGORIES")) || defined('MANAGE_CATEGORIES')) {

2) replace it with the next one

if (($current_area == "C") || defined('MANAGE_CATEGORIES')) {


Then edit categories.tpl replace with the following code after {if $config.General.root_categories eq "Y"}


{foreach from=$categories item=c}
<font class="CategoriesList">{$c.category}</font>
<ul>
{foreach from=$allcategories item=cat}
{if $cat.parentid eq $c.categoryid}[*]<font class="CategoriesList">{$cat.category}</font>
{/if}
{/foreach}[/list]{/foreach}

Hope this helps ...

Regards

Shafiq :sK
__________________
Jeremy Freeman
EZWatch Store
X-Cart v4.1.5
Reply With Quote
  #25  
Old 10-03-2006, 12:31 PM
 
Jeremy.Freeman Jeremy.Freeman is offline
 

Advanced Member
  
Join Date: Mar 2005
Posts: 79
 

Default Re: ALWAYS display first level subcats beneath root cats

Fixed it.. you need to comment out the following line in include/categories.php to sort the subcategories by pos:

usort($all_categories, "func_categories_sort");

I should appear around line 165ish

Quote:
Originally Posted by Jeremy.Freeman
This works great on 4.1.3! However, the subcategories are not displaying in the order they are specified to order by (based on pos).. any idea how to do that?
__________________
Jeremy Freeman
EZWatch Store
X-Cart v4.1.5
Reply With Quote
  #26  
Old 11-30-2006, 08:51 AM
 
themidnightwill themidnightwill is offline
 

Newbie
  
Join Date: Aug 2006
Posts: 7
 

Default Re: ALWAYS display first level subcats beneath root cats

Hi,

I am using X-Cart 4.1.2 Gold, and would like to use your modification. I do not see a skin1/categories.tpl file. Am I missing some interpretation of your post?

Thanks,

Will
__________________
-Michael Shearer

-------------------------------------

X-Cart version 4.1.2, PHP 4.4.4, MySQL server 4.0.26, MySQL client 4.0.26, Apache/1.3.37 (Unix) Vortech_PHP/1.0, FrontPage/5.0.2.2623, mod_ssl/2.8.28, OpenSSL/0.9.7e-p1, FreeBSD, Perl 5.008007, XML parser (expat) found
Reply With Quote
  #27  
Old 01-05-2007, 11:28 AM
 
dtpub dtpub is offline
 

Member
  
Join Date: May 2006
Posts: 25
 

Default Re: ALWAYS display first level subcats beneath root cats

Hope someone is still looking at this one.

I used this code in the /customer/categories.tpl.

It does display the subcategories under the Main Categories as hoped.

The first issue is, that the subcat list items are not linked to the subcategories pages.

The second issue is that I have made the menu column wider, and the sub cat list does not have line breaks, so they run on as one line.

Can some one help with this?

Thanks,
Gary

Here is the code I'm using:


{* $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="`$fancycategories_config.modules_path`/fancy_categories.tpl"}
{else}
{if $config.General.root_categories eq "Y"}
{section name=cat_num loop=$categories}
<FONT class="CategoriesList"><A href="home.php?cat={$categories[cat_num].categoryid}" class="VertMenuItems">{$categories[cat_num].category}</A></FONT><BR>
{section name=subcat loop=$allcategories}
{if $allcategories[subcat].parentid eq $categories[cat_num].categoryid}
{$allcategories[subcat].category}
{/if}
{/section}
{/section}
{else}
{section name=cat_num loop=$subcategories}
<FONT class="CategoriesList"><A href="home.php?cat={$subcategories[cat_num].categoryid}" class="VertMenuItems">{$subcategories[cat_num].category}</A></FONT><BR>
{/section}
{/if}
{/if}
{/capture}
{ include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_title=$lng.lbl_categories menu_content=$smarty.capture.menu }
__________________
v4.1.6 Unix OSX 10.5.6 PHP 5.x
MySQL various versions
Reply With Quote
  #28  
Old 01-07-2007, 03:05 PM
  dalmuti's Avatar 
dalmuti dalmuti is offline
 

eXpert
  
Join Date: Oct 2004
Location: Kansas
Posts: 343
 

Default Re: ALWAYS display first level subcats beneath root cats

Here is my categories.tpl file:

Quote:

{* $Id: categories.tpl,v 1.26 2005/11/17 06:55:37 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}
<font class="CategoriesList"><a href="home.php?cat={$c.categoryid}" class="VertMenuItems">{$c.category}</a></font><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}
{/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}


The text in bold will correct both issues for you.

Thanks,

Louise
__________________
Louise

Studio 57 Designs - X-Cart Customization
Providing X-Cart Services since 2004
Hottest Blog Directory - Submit Your Blog for a Free Listing
Reply With Quote

The following user thanks dalmuti for this useful post:
donavichi (10-25-2009)
  #29  
Old 02-16-2007, 01:32 AM
 
skeep5 skeep5 is offline
 

Advanced Member
  
Join Date: Feb 2007
Posts: 47
 

Default Re: ALWAYS display first level subcats beneath root cats

Quote:
Originally Posted by bluski
Thanks for the mod. Just what I was seeking, and there were only old posts for older versions. So thanks, ExoZed!!!

I modified your code so that all main categories will show on home page and when you click on a main category, only the subcats for that cat will show (and stay shown!) while the main categories will always show.

I'm new to PHP and Smarty, so someone please check my code.


Code:
{* $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="`$fancycategories_config.modules_path`/fancy_categories.tpl"} {else} {if $config.General.root_categories eq "Y"} {section name=cat_num loop=$categories} <FONT class="CategoriesList">{$categories[cat_num].category}</FONT> {if $cat eq $categories[cat_num].categoryid || $current_category.parentid eq $categories[cat_num].categoryid} {section name=subcat loop=$allcategories} {if $allcategories[subcat].parentid eq $categories[cat_num].categoryid} {$allcategories[subcat].category} {/if} {/section} {/if} {/section} {else} {section name=cat_num loop=$subcategories} <FONT class="CategoriesList">{$subcategories[cat_num].category}</FONT> {/section} {/if} {/if} {/capture} { include file="menu.tpl" dingbats="dingbats_categorie.gif" menu_content=$smarty.capture.menu }

This works for me using version 4.1.6. Can anyone show me how to keep the 2nd level subcategories showing, all the time? Thanks in advance.
__________________
---------------
Brandon Larsen
---------------
X-Cart version 4.4.3
X-Cart version 4.1.9
X-Cart version 4.1.10
Reply With Quote
  #30  
Old 02-21-2007, 10:07 AM
  chris2002's Avatar 
chris2002 chris2002 is offline
 

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

Default Re: ALWAYS display first level subcats beneath root cats

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
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



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 01:05 AM.

   

 
X-Cart forums © 2001-2020