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

Mod for subcategories in columns with descriptions and icons
 
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features
 
Thread Tools Search this Thread
  #131  
Old 06-29-2006, 01:59 AM
 
scottWB scottWB is offline
 

Member
  
Join Date: Jun 2006
Posts: 19
 

Default

This works for me to get multiple row categories with icons in 4.1.1. My use doesn't need text or descriptions, so you'll have to add that back if you do. Still needs some cleaning up, but it works. This is just a snip from the template.

Code:
{if $subcategories} <table border="0" cellspacing="5" width="100%"> <tr> {foreach from=$subcategories item=subcat} {if $tmp is not div by 2} </tr><tr valign="top"> {/if} <td class="SubcatTitle"><a href="home.php?cat={ $subcat.categoryid }" title="{ $subcat.category }"> [img]image.php?id={$subcat.categoryid}&amp;type=C[/img] </a></td> {assign var="tmp" value=$tmp+1} {/foreach} </tr></table> {/if}
__________________
X-Cart Pro 4.1.10
PHP 4.4.2
Apache 2.0.52 RedHat
MySQL 4.1.20
Reply With Quote
  #132  
Old 06-29-2006, 04:02 PM
 
mffowler mffowler is offline
 

X-Adept
  
Join Date: Mar 2003
Location: Melbourne, Australia
Posts: 811
 

Default

Close, but use the file system for the cat. images. The code needs to be reworked using sections to allow for multiple columns (am trying it now), but here's your previous code with names and content and using the file system. I have left your database image call to see what was coded out...
Code:
{if $subcategories} <table border="0" cellspacing="5" width="100%"> <tr> {foreach from=$subcategories item=subcat} {if $tmp is not div by 2} </tr><tr valign="top"> {/if} <td class="SubcatTitle"><a href="home.php?cat={ $subcat.categoryid }" title="{ $subcat.category }">{if $subcat.icon_url}[img]{$subcat.icon_url}[/img]{else}[img]{$xcart_web_dir}/default_icon.gif[/img]{/if} {* [img]image.php?id={$subcat.categoryid}&amp;type=C[/img] *} </a> <font class="ItemsList">{ $subcat.category|escape }</font> {if $config.Appearance.count_products eq "Y"} {if $subcat.product_count}{ $subcat.product_count } {$lng.lbl_products} {elseif $subcat.subcategory_count}{ $subcat.subcategory_count } {$lng.lbl_categories|lower} {/if} {/if} </td> {assign var="tmp" value=$tmp+1} {/foreach} </tr></table> {/if}
- Mike
__________________
4.1.9
Reply With Quote
  #133  
Old 06-29-2006, 08:50 PM
 
MCM MCM is offline
 

Senior Member
  
Join Date: Dec 2005
Posts: 114
 

Default

This is a great mod! I've got an idea for an addition and two questions:

First, I've made the Icon/Category one link, instead of two on top of each other... no big deal. I've also added a title tag to the link, though, so when someone hovers, there can be text... this seems like it should be good for adding keyword density to the link. The problem is, I can't find the smarty tag for the category description, which is, in my opinion, highly appropriate for the title tag. If you can tell me the tag, I'd be very grateful.

Second, when a category has no products, there is nothing beneath the Category name. Is there a way for it to say "0 Items" instead of it being blank?

Here's my subcategories.tpl:

Code:
{* $Id: subcategories.tpl,v 1.43.2.2 2004/10/07 07:08:51 max Exp $ *} {if $active_modules.Bestsellers ne "" and $config.Modules.bestsellers_menu ne "Y"} {include file="modules/Bestsellers/bestsellers.tpl"} {/if} {if ($navigation_page eq "")||($navigation_page eq "1")}{$current_category.description|regex_replace:"/[\n]/":" "} {/if} {capture name=dialog} {assign var="tmp" value="0"} {section name=cat_num loop=$subcategories} {if $subcategories[cat_num].category}{assign var="tmp" value="1"}{/if} {/section} {* ==================== Sub categories mod start *} {section name=cat_num loop=$subcategories} { if %cat_num.first% } <table width="100%" border="0" align="center" cellpadding="5" cellspacing="0"> {/if} { if %cat_num.index% is div by 2} <tr> {/if} <td align="center" valign="top"> <a title="Alternate Text" href="home.php?cat={ $subcategories[cat_num].categoryid }"> [img]{$xcart_web_dir}/icon.php?categoryid={$subcategories[cat_num].categoryid}[/img] <font size="3">{ $subcategories[cat_num].category|escape } </font></a> { $subcategories[cat_num].description|escape } {if $config.Appearance.count_products eq "Y"} {if $subcategories[cat_num].product_count} ({ $subcategories[cat_num].product_count } Items) {elseif $subcategories[cat_num].subcategory_count} ({ $subcategories[cat_num].subcategory_count } Subcategories) {/if} {/if} </td> { if %cat_num.last% } </tr> </table> {/if} {/section} {* ==================== Sub categories mod end *} {if $tmp and $products ne "" } <BR clear="left"> <HR size="1" noshade> {/if} {if $products} {if $sort_fields} <DIV align="right">{include file="main/search_sort_by.tpl" sort_fields=$sort_fields selected=$search_prefilled.sort_field direction=$search_prefilled.sort_direction url="home.php?cat=`$cat`&"}</DIV> {/if} {if $total_pages gt 2} { include file="customer/main/navigation.tpl" } {/if} <HR size="1" width="100%"> {include file="customer/main/products.tpl" products=$products} {/if} {if $products eq "" and $tmp eq "0"} {$lng.txt_no_products_in_man} {/if} {/capture} {include file="dialog.tpl" title=$current_category.category content=$smarty.capture.dialog extra="width=100%"} {if $products eq ""} {if $f_products ne ""} {include file="customer/main/featured.tpl"} {/if} {/if} { include file="customer/main/navigation.tpl" }

Jeremy
__________________
Version 4.0.17/4.0.18
Reply With Quote
  #134  
Old 06-30-2006, 01:36 PM
 
MCM MCM is offline
 

Senior Member
  
Join Date: Dec 2005
Posts: 114
 

Default

Oh, does anyone know what tag to add so (0 Items) appears when there are no items in a subcategory? Right now, (# Items) only shows up if the subcategory actually has items available.

Thanks,

Jeremy
__________________
Version 4.0.17/4.0.18
Reply With Quote
  #135  
Old 07-06-2006, 01:21 AM
 
kenlerch kenlerch is offline
 

Member
  
Join Date: Apr 2005
Posts: 26
 

Default Code Modified for use with DSEFU

Hey guys, I just got the code working with DSEFU's , v 4.0.17 Pro and figured it would be of use here since both seem to be a popular mod and I had seen at least one request in this thread.

Notes:
* This is the entire code for subcatecories.tpl
* Modified per Balinor's post on page 8 to use file system for images instead of a call to the database
* This code uses 4 columns. You have to set n in "div by n" to the (number of columns + 1). I also changed the width of the table to work with four columns, thus the "25%". Just change that value to the appropriate number for your number of columns (33% for 3, 20% for 5, etc).
* I used an image height of 50, so you may need to change that to your needs as well.

Thanks for this mod, it's definitely a good one. And thanks for this forum in general. I've found lots of good stuff here and figured I'd give something back with this post.

Code:
{* $Id: subcategories.tpl,v 1.43.2.2 2004/10/07 07:08:51 max Exp $ *} {if $active_modules.Bestsellers ne "" and $config.Modules.bestsellers_menu ne "Y"} {include file="modules/Bestsellers/bestsellers.tpl"} {/if} {if ($navigation_page eq "")||($navigation_page eq "1")}{$current_category.description|regex_replace:"/[\n]/":" "} {/if} {capture name=dialog} {assign var="tmp" value="0"} {section name=cat_num loop=$subcategories} {if $subcategories[cat_num].category}{assign var="tmp" value="1"}{/if} {/section} {* ==================== Sub categories mod start *} {foreach from=$subcategories item=subcat name="subcats"} { if $smarty.foreach.subcats.first } <table width="100%" border="0" align="center" cellpadding="5" cellspacing="0"> {/if} { if $smarty.foreach.subcats.iteration is div by 5} <tr> {/if} <td align="center" valign="top" width="25%"> <a href="{seo_link cat_name=$subcat.category cat_id=$subcat.categoryid}"> {if $subcat.icon_url}[img]{$subcat.icon_url}[/img]{else}[img]{$xcart_web_dir}/default_image.gif[/img]{/if} </a> <a href="{seo_link cat_name=$subcat.category cat_id=$subcat.categoryid}"> <font size="1">{$subcat.category|escape}</font></a> {if $config.Appearance.count_products eq "Y"} {if $subcat.product_count}{ $subcat.product_count } {$lng.lbl_items} {elseif $subcat.subcategory_count}{ $subcat.subcategory_count } {$lng.lbl_categories|lower} {/if} {/if} </td> { if $smarty.foreach.subcats.last } </tr> </table> {/if} {/foreach} {* ==================== Sub categories mod end *} {if $tmp and $products ne "" } <BR clear="left"> <HR size="1" noshade> {/if} {if $products} {if $sort_fields} <DIV align="right">{include file="main/search_sort_by.tpl" sort_fields=$sort_fields selected=$search_prefilled.sort_field direction=$search_prefilled.sort_direction url="home.php?cat=`$cat`&"}</DIV> {/if} {if $total_pages gt 2} { include file="customer/main/navigation.tpl" } {/if} <HR size="1" width="100%"> {include file="customer/main/products.tpl" products=$products} {/if} {if $products eq "" and $tmp eq "0"} {$lng.txt_no_products_in_man} {/if} {/capture} {include file="dialog.tpl" title=$current_category.category content=$smarty.capture.dialog extra="width=100%"} {if $products eq ""} {if $f_products ne ""} {include file="customer/main/featured.tpl"} {/if} {/if} { include file="customer/main/navigation.tpl" }
__________________
Version 4.0.17 Pro
Reply With Quote
  #136  
Old 07-06-2006, 04:19 AM
  photo's Avatar 
photo photo is offline
 

X-Wizard
  
Join Date: Feb 2006
Location: UK
Posts: 1,146
 

Default

Quote:
Originally Posted by mffowler
Close, but use the file system for the cat. images. The code needs to be reworked using sections to allow for multiple columns (am trying it now), but here's your previous code with names and content and using the file system. I have left your database image call to see what was coded out...
Code:
{if $subcategories} <table border="0" cellspacing="5" width="100%"> <tr> {foreach from=$subcategories item=subcat} {if $tmp is not div by 2} </tr><tr valign="top"> {/if} <td class="SubcatTitle"><a href="home.php?cat={ $subcat.categoryid }" title="{ $subcat.category }">{if $subcat.icon_url}[img]{$subcat.icon_url}[/img]{else}[img]{$xcart_web_dir}/default_icon.gif[/img]{/if} {* [img]image.php?id={$subcat.categoryid}&amp;type=C[/img] *} </a> <font class="ItemsList">{ $subcat.category|escape }</font> {if $config.Appearance.count_products eq "Y"} {if $subcat.product_count}{ $subcat.product_count } {$lng.lbl_products} {elseif $subcat.subcategory_count}{ $subcat.subcategory_count } {$lng.lbl_categories|lower} {/if} {/if} </td> {assign var="tmp" value=$tmp+1} {/foreach} </tr></table> {/if}
- Mike

Did you ever make any progress on this?

Thanks
__________________
v4.1.10
In Dev v4.5.x


"If you don't keep an eye on your business, someone else will."
Reply With Quote
  #137  
Old 07-08-2006, 05:38 PM
 
mrkenzie mrkenzie is offline
 

Senior Member
  
Join Date: May 2006
Posts: 182
 

Default

This is the code that I have and works with 4.1.0. I have added several things to this modification. Not only will it display the categories in columns, it will:
1. display the default "No Image Avail." image if one is not assigned
2. display "0 Products" if there are no subcategories or products for a particular category.
3. it will show the subcategory DESCRIPTION if there is one when you hover over the subcategory link.

Take it, use it, modify it. Good luck!

Here is what you add to the Skin1.css
Code:
.ColumnTitles { padding-left: 5px; text-align: center; width: 33%; }

Find this in categories.php:
Code:
$_categories = func_query_hash("SELECT $to_search FROM $sql_tbl[categories] USE INDEX (am) $join_tbl ".(!empty($search_condition)?"WHERE ".implode(" AND ", $search_condition):"")." GROUP BY $sql_tbl[categories].categoryid ".$sort_condition, "categoryid", false);

and replace with this (in order to get the category description):
Code:
$_categories = func_query_hash("SELECT $to_search, $sql_tbl[categories].description FROM $sql_tbl[categories] USE INDEX (am) $join_tbl ".(!empty($search_condition)?"WHERE ".implode(" AND ", $search_condition):"")." GROUP BY $sql_tbl[categories].categoryid ".$sort_condition, "categoryid", false);

Here is the code that I changed in subcategories.tpl:
Code:
{if $subcategories} <table cellspacing="5" width="100%" border="0"> <tr> {foreach from=$subcategories item=subcat} {if $tmp is div by 3} </tr><tr><td colspan="3"></td></tr><tr valign="top"> {/if} { if $tmp and $first_subcat ne "Y" } {assign var="tmp" value=0} {assign var="first_subcat" value="Y"} {/if} <td class="ColumnTitles" valign="top"><a title="{$subcat.description}" href="home.php?cat={ $subcat.categoryid }"><img src="{if $subcat.icon_url}{$subcat.icon_url}{else}{$xcart_web_dir}/default_image.gif{/if}" alt="" /> <font class="ItemsList">{ $subcat.category|escape }</font></a> {if $config.Appearance.count_products eq "Y"} {if $subcat.product_count}{ $subcat.product_count } {$lng.lbl_products} {elseif $subcat.subcategory_count}{ $subcat.subcategory_count } {$lng.lbl_categories|lower} {else} 0 Products {/if} {/if} {assign var="tmp" value=$tmp+1} {/foreach} </table> {/if}

By Default, it shows 3 columns. If you want to change the number of columns, then just change all the 3's to the number of columns you want in this line of code (from above):
Code:
{if $tmp is div by 3} </tr><tr><td colspan="3"></td></tr><tr valign="top"> {/if}
And then change the following line in skin1.css (from above) for the appropriate td width %
Code:
.ColumnTitles { padding-left: 5px; text-align: center; width: 33%; }

I added a blank row between each row of subcategories, just to seperate the rows a little so it does not look so crowded.

Let me know if there are any problems.
__________________
Mike Kenzie
X Cart Gold Ver. 4.1.3
X-RMA
X-AOM
X-Product Comparison
Reply With Quote
  #138  
Old 07-08-2006, 06:14 PM
  dalmuti's Avatar 
dalmuti dalmuti is offline
 

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

Default

Excellent! Works fine in 4.1.2!

Thank you,

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
  #139  
Old 07-08-2006, 08:32 PM
 
robf robf is offline
 

Advanced Member
  
Join Date: May 2006
Posts: 61
 

Default

Right on, I've been waiting a while for someone to get the right code, thanks a lot Mike, it works great on 4.1.2
__________________
x-cart 4.1.6
PHP 4.4.2
MySQL server 4.0.26-log
MySQL client 5.0.20
Operation system FreeBSD
Perl 5.008008
Reply With Quote
  #140  
Old 07-08-2006, 09:20 PM
 
mffowler mffowler is offline
 

X-Adept
  
Join Date: Mar 2003
Location: Melbourne, Australia
Posts: 811
 

Default

Thanks Mike. Works beautifully and a great sign that the forum will commence it's move to supprting 4.1.x users....

- Mike
__________________
4.1.9
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features


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 11:11 AM.

   

 
X-Cart forums © 2001-2020