X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Subcategories Icon (https://forum.x-cart.com/showthread.php?t=6378)

trickdog101 02-23-2004 09:15 AM

Subcategories Icon
 
I am looking for some information that I thought I saw on here before.

Basically what I am trying to do is this...

I have category listings down the side of the page. When a customer clicks on the category listings, the main body of the page is populated with a textual listing of the subcategoires.

What I would like to do is modify the the customer/main/subcategories.tpl file so that instead of using text to list the subcat, it uses the subcat's icon.

Also, I would like to list them in three columns across.

Thanks for the help

Trick Dog!

finestshops 02-27-2004 07:56 PM

Re: Subcategories Icon
 
Quote:

Originally Posted by trickdog101
Also, I would like to list them in three columns across.


Try this for "subcategories.tpl"

Code:

{* $Id: subcategories.tpl,v 1.29 2002/11/26 14:55:13 alfiya Exp $ *}
{ include file="location.tpl" }
{if $active_modules.Bestsellers ne "" and $config.Modules.bestsellers_menu ne "Y"}


 
{include file="modules/Bestsellers/bestsellers.tpl"}
{/if}


 
{ include file="customer/main/navigation.tpl" }
{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}

{section name=cat_num loop=$subcategories}

{ if %cat_num.first% }
<table border=0 cellspacing=5 width=100%>
{/if}

  {if $smarty.section.cat_num.index is div by 2}
    </tr><tr valign="top">
  {/if}

        <td valign="top" width="70" align="center">
        <a class="alt" href="home.php?cat={ $subcategories[cat_num].categoryid }">
        [img]../icon.php?categoryid={$subcategories[cat_num].categoryid}[/img]
        </a>
        </td>
        <td align=left><a class="alt" href="home.php?cat={ $subcategories[cat_num].categoryid }">
        {$subcategories[cat_num].category|escape}</a>

        { $subcategories[cat_num].description|escape }
{if $config.Appearance.count_products eq "Y"}


<font class=Text>
{if $subcategories[cat_num].product_count}
{ $subcategories[cat_num].product_count } {$lng.lbl_products}
{elseif $subcategories[cat_num].subcategory_count}
{ $subcategories[cat_num].subcategory_count } {$lng.lbl_categories|lower}
{/if}
</font>
{/if}


        </td>

{ if %cat_num.last% }
</tr></table>
{/if}

{/section}
{if $tmp and $products ne "" }
<br clear=_all>{*<hr size=1 noshade>*}
{/if}

{if $products eq "" and $tmp eq "0"}
{$lng.txt_no_products_in_cat}
{/if}




{include file="customer/main/products.tpl" products=$products}

{/capture}
{include file="dialog.tpl" title=$current_category.category|regex_replace:"/.*\//":"" 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" }


you can see it in action here:

http://www.bitsnspurs.com/store/customer/home.php?cat=13

if you need 3 columns chnage
Code:

div by 2
to
Code:

div by 3

trickdog101 03-02-2004 05:53 AM

Thanks a bunch! That did it!

www.outhousemall.com

skyking 04-24-2004 12:47 PM

Thank you.

mream 10-05-2004 02:25 PM

Doesn't that code remove the "x products" or "x categories" count on the right-hand side? Is there an easy way to combine graphic and count?

mream 10-07-2004 10:03 AM

anyone?

finestshops 10-07-2004 10:42 AM

Quote:

Originally Posted by mream
Doesn't that code remove the "x products" or "x categories" count on the right-hand side? Is there an easy way to combine graphic and count?


I updated the code above to show products or category counts after category description. I did not have a chance to test it.

mream 10-08-2004 09:06 AM

That worked. I made some format changes, and moved some stuff around, but it worked as posted and you can see it here, with my changes:

http://www.raiseyourpulse.com/customer/home.php?cat=262

TheComputerGuy 10-12-2004 05:55 AM

Ok, this is exactly what i've been looking for! But there is something i don't get in regrads to have sub-category icons:

How do I get the Icons to show for each sub category? I notied the code went like this:
Code:

[img]../icon.php?categoryid={$subcategories[cat_num].categoryid}[/img]

But i have no idea where i put the icon images and how i link them to that img src (../icon.php?categoryid={$subcategories[cat_num].categoryid})?

If i'm missing something, can someone please feel me in. Thank you

finestshops 10-12-2004 02:36 PM

Quote:

Originally Posted by TheComputerGuy
How do I get the Icons to show for each sub category? But i have no idea where i put the icon images


You can assign icon to each category in "Categories" interface.
If you are using v4.X.X you will have to change

Code:

<img src="../icon.php

to

Code:

<img src="icon.php

adamsteinhoff 10-13-2004 12:01 PM

I am trying to get this mod working for my site (www.eArtPark.com). For some reason, neither the description or product counts are displaying. What am I doing wrong here?

Quote:

{if $active_modules.Bestsellers ne "" and $config.Modules.bestsellers_menu ne "Y"}



{include file="modules/Bestsellers/bestsellers.tpl"}
{/if}



{ include file="customer/main/navigation.tpl" }
{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}

{section name=cat_num loop=$subcategories}

{ if %cat_num.first% }
<table border=0 cellspacing=5 width=100%>
{/if}

{if $smarty.section.cat_num.index is div by 2}
</tr><tr valign="top">
{/if}

<td valign="top" width="70" align="center">
<a class="alt" href="home.php?cat={ $subcategories[cat_num].categoryid }">
[img]../icon.php?categoryid={$subcategories[cat_num].categoryid}[/img]
</a>
</td>
<td align=left><a class="alt" href="home.php?cat={ $subcategories[cat_num].categoryid }">
{$subcategories[cat_num].category|escape}</a>

{ $subcategories[cat_num].description|escape }
{if $config.Appearance.count_products eq "Y"}


<font class=Text>
{if $subcategories[cat_num].product_count}
{ $subcategories[cat_num].product_count } {$lng.lbl_products}
{elseif $subcategories[cat_num].subcategory_count}
{ $subcategories[cat_num].subcategory_count } {$lng.lbl_categories|lower}
{/if}
</font>
{/if}


</td>

{ if %cat_num.last% }
</tr></table>
{/if}
{/section}
{* ==================== Sub categories mod end *}
{if $tmp and $products ne "" }
<br clear=_all>{*<hr size=1 noshade>*}
{/if}

{if $products ne "" and $tmp eq "0"}



{include file="customer/main/products.tpl" products=$products}
{/if}

{if $products eq "" and $tmp eq "0"}
{$lng.txt_no_products_in_cat}
{/if}

{/capture}
{include file="dialog.tpl" title=$current_category.category|regex_replace:"/.*\//":"" content=$smarty.capture.dialog extra="width=100%"}

{if $products eq "" and $f_products ne ""}






{include file="customer/main/featured.tpl"}
{/if}
{ include file="customer/main/navigation.tpl" }


prai 12-16-2004 11:18 PM

Strange Error with the category icon script
 
I've tried to implemt the subcategories.tpl on my site. I am running 4.0.8 in test mode at the moment.

Everything seems fine, I can click on a category on the left menu to open up and view the sub-categories...where I can see the category icons displaying fine...but the strange thing is this...above the category icons I can see TWO navigation paths as shown below one on top of the other , there should only be one....but i don't know how to fix it within the script.

б╩ ThaiBoutique б╩ Silk Scarfs

б╩ ThaiBoutique б╩ Silk Scarfs

Any thoughts on how i can fix this ?????

Thx Peter

prai 12-16-2004 11:47 PM

Fixed My Problem
 
I managed to figure out my problem, the answer to my posting is this

Within the subcategories.tpl .... remove the 1st line.

{ include file="location.tpl" }


Peter

donavichi 12-17-2004 03:10 PM

Great Mod, thanks 27 stars. Works a treat on 3.5.X

tntdesigns 03-06-2005 11:35 PM

Test under Image
 
Hi
Any one knows how I can get my text center under the Icon?
Thanks :?

balinor 03-07-2005 03:31 AM

Change align=left to align=center :)

kpriest 09-18-2005 04:16 PM

Similar, but hopefully simpler situation:

4.0.13 out-of-box subcategories.tpl has the parent category icon showing up IF THERE ARE SUBCATEGORIES and DOES NOT show the category icon for the lowest level subcategories.

I need this to work in reverse - If there are subcategories, DO NOT SHOW the icon. If there are no subcategories (Lowest level) SHOW the icon.

Seems like that should be the default behavior anyway. Iam chasing my tail going through the template trying different things and can't get it to work. ANY IDEAS?

finestshops 09-18-2005 07:23 PM

Quote:

Originally Posted by kpriest
Similar, but hopefully simpler situation:

I need this to work in reverse - If there are subcategories, DO NOT SHOW the icon. If there are no subcategories (Lowest level) SHOW the icon.


just change

{if $tmp} [img]{if $current_category.icon_url}{$current_category.icon _url}{else}{$xcart_web_dir}/icon.php?categoryid={$cat}{/if}[/img] {/if}

to

{if ne $tmp} [img]{if $current_category.icon_url}{$current_category.icon _url}{else}{$xcart_web_dir}/icon.php?categoryid={$cat}{/if}[/img] {/if}

in skin1/customer/main/subcategories.tpl template

kpriest 09-19-2005 12:16 AM

Thanks Anton -

I ended up working through it and incorporated the mod in the forum also. Here is what it looks like:
Code:

{* $Id: subcategories.tpl,v 1.43.2.2 2004/10/07 07:08:51 max Exp $ *}
{if !$subcategories}
        [img]{$xcart_web_dir}/icon.php?categoryid={$cat}[/img]
{/if}
{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}

{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="bottom">
<a href="home.php?cat={ $subcategories[cat_num].categoryid }">
[img]{$xcart_web_dir}/icon.php?categoryid={$subcategories[cat_num].categoryid}[/img]</a>
 
<a href="home.php?cat={ $subcategories[cat_num].categoryid }">
<font size="1">{ $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 } {$lng.lbl_items}
{elseif $subcategories[cat_num].subcategory_count}
({ $subcategories[cat_num].subcategory_count } Subcategories)
{/if}
{/if}
</td>
{ if %cat_num.last% }
</tr>
</table>
{/if}
{/section}

{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" }

This works perfectly for me - if there are subcategories, show the name and logo in 2 column format, NO image for the parent category. If no subcategories, show the category image.

dprice.sf 12-15-2005 12:02 PM

Hey Great Mod.

Have a question regarding the product count and warning message.

I've managed to remove the products count from my tpl file but still have a message at the bottom of the table:

"No matching products found"

Tried removing the some of the product code below the subcat table to get rid of it but didn't work.

Heres what my code looks like after the revisions.

Code:

{* $Id: subcategories.tpl,v 1.29 2002/11/26 14:55:13 alfiya Exp $ *}
{if $active_modules.Bestsellers ne "" and $config.Modules.bestsellers_menu ne "Y"}



{include file="modules/Bestsellers/bestsellers.tpl"}
{/if}



{ include file="customer/main/navigation.tpl" }
{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}

{section name=cat_num loop=$subcategories}

{ if %cat_num.first% }
<table border=0 cellspacing=5 width=100%>
{/if}

  {if $smarty.section.cat_num.index is div by 2}
    </tr><tr valign="top">
  {/if}

  <td valign="top" width="70" align="center">
  <a class="alt" href="home.php?cat={ $subcategories[cat_num].categoryid }">
  [img]icon.php?categoryid={$subcategories[cat_num].categoryid}[/img]
  </a>

  <a class="alt" href="home.php?cat={ $subcategories[cat_num].categoryid }">
  {$subcategories[cat_num].category|escape}</a>

  { $subcategories[cat_num].description|escape }
{if $config.Appearance.count_products eq "Y"}


{/if}


  </td>
            { if %cat_num.last% }
    </tr>
</table>
{/if}

{/section}
{if $tmp and $products ne "" }
<br clear=_all>{*<hr size=1 noshade>*}
{/if}



{include file="customer/main/products.tpl" products=$products}

{/capture}
{include file="dialog.tpl" title=$current_category.category|regex_replace:"/.*\//":"" 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" }


finestshops 12-15-2005 01:29 PM

Quote:

Originally Posted by dprice.sf
"No matching products found"


Hi,

I think you have change in products.tpl file:

from

Code:

{else}
{$lng.txt_no_products_found}


to

Code:

{else}
{* $lng.txt_no_products_found *}


dprice.sf 12-15-2005 01:53 PM

thanks 27stars - that did it

ddsman 12-18-2005 08:36 PM

Great Mod - But What if you are using File System
 
This mod works great if you are using the database to store the category images. But what if you change to a file system? When I click on the properties of a subcategory image I get:

Code:

http://www.profilespa.com/onlinestore/icon.php?categoryid=277

but if I check an item image I get:

Code:

http://www.profilespa.com/onlinestore/images/catalog/t_13011.gif

Since my DB performance sucks I would really like to change this to use my file system. Can I do this?

The code i'm using for subcategories.tpl in version 4.017 is:
Code:

{* $Id: subcategories.tpl,v 1.29 2002/11/26 14:55:13 alfiya Exp $ *}
{if $active_modules.Bestsellers ne "" and $config.Modules.bestsellers_menu ne "Y"}


 
{include file="modules/Bestsellers/bestsellers.tpl"}
{/if}


 
{ include file="customer/main/navigation.tpl" }
{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}

{section name=cat_num loop=$subcategories}

{ if %cat_num.first% }
<table border=0 cellspacing=5 width=100%>
{/if}

  {if $smarty.section.cat_num.index is div by 2}
    </tr><tr valign="top">
  {/if}

  <td valign="top" width="70" align="center">
  <a class="alt" href="home.php?cat={ $subcategories[cat_num].categoryid }">
  [img]icon.php?categoryid={$subcategories[cat_num].categoryid}[/img]
  </a>
  </td>
  <td align=left><a class="alt" href="home.php?cat={ $subcategories[cat_num].categoryid }">
  {$subcategories[cat_num].category|escape}</a>
 
  { $subcategories[cat_num].description|escape }
{if $config.Appearance.count_products eq "Y"}

 
<font class=Text>
{if $subcategories[cat_num].product_count}
{ $subcategories[cat_num].product_count } {$lng.lbl_products}
{elseif $subcategories[cat_num].subcategory_count}
{ $subcategories[cat_num].subcategory_count } {$lng.lbl_categories|lower}
{/if}
</font>
{/if}

 
  </td>

{ if %cat_num.last% }
</tr></table>
{/if}

{/section}
{if $tmp and $products ne "" }
<br clear=_all>{*<hr size=1 noshade>*}
{/if}

{if $products eq "" and $tmp eq "0"}
{$lng.txt_no_products_in_cat}
{/if}



 
{include file="customer/main/products.tpl" products=$products}

{/capture}
{include file="dialog.tpl" title=$current_category.category|regex_replace:"/.*\//":"" 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" }


Paul H 12-25-2005 02:46 PM

Hey since a helpful person on here told me how to use Dreamweaver to alter my code I decided to try this mod and it works great ! Now the only problem is since I've been lazy and not bothered clipping my images to size is there a little bit of code I can put in there to display the icon/image at a certain size like 200x200 or 150 x 150 ? as i use the larger image in product detail too which prevents me running a batch job in Fireworks.

Thanks
and Merry Christmas

Touchy 01-06-2006 07:10 PM

Description not coming through
 
Hi, This mod is great!!

One question though. I have copied both versions into my cart to try them out and they both work except for the won't bring in the sub category descriptions????

The piece of code I think is try to call it out is:

<td align=left><a class="alt" href="home.php?cat={ $subcategories[cat_num].categoryid }">
{$subcategories[cat_num].category|escape}</a>

{$subcategories[cat_num].description|escape}
{if $config.Appearance.count_products eq "Y"}

However it won't bring it in. Can anybody help

I tried searching for subcategories[cat.num]. Is this a database input?? I do not have a xcart_subcategories database.

Any help to get this working would be great.

Touchy 01-10-2006 02:20 PM

Subscriptions Icon
 
Hey manage to get this working with help from 27stars and anoher forum link

Thought I'd shared in case anybody else is looking at this.

You need to go to the categories.php file and change the code

Original Code:

Code:

if ($short_list) {
                $to_search = "$sql_tbl[categories].categoryid,$sql_tbl[categories].parentid,$sql_tbl[categories].categoryid_path,$sql_tbl[categories].category,$sql_tbl[categories].product_count,$sql_tbl[categories].avail,$sql_tbl[categories].order_by";
        } else {
                $to_search = "$sql_tbl[categories].*";


New code:

Code:

if ($short_list) {
                $to_search = "$sql_tbl[categories].categoryid,$sql_tbl[categories].description,$sql_tbl[categories].parentid,$sql_tbl[categories].categoryid_path,$sql_tbl[categories].category,$sql_tbl[categories].product_count,$sql_tbl[categories].avail,$sql_tbl[categories].order_by";
        } else {
                $to_search = "$sql_tbl[categories].*";


Hope this helps.

The only thing else I'm trying to do is get the sub category description to display HTML like the product descriptions.

Can anybody help.
Still not very code with code.

Thanks

Glowinafuse 01-30-2006 03:55 PM

This is what I have been looking for...

This helps with having over 400 categories

Thanks for posting...

Glowinafuse 01-31-2006 08:31 PM

I tried to get the names of the sub cats under the pic. But no help... I tried the left to center. But it did nothing.

Can someone be more specific on what I need to do.

Thanks in advance,

smartoption 03-02-2006 12:53 PM

This is great, i have managed to get the list into rows of 3's, i have also changed the icon to the null image but this leaves a gap between the rows. Can anyone tell me how to close these gaps up or make it so the category does not look for an image?

Thanks

finestshops 03-04-2006 07:03 PM

Quote:

Originally Posted by smartoption
Can anyone tell me how to close these gaps up or make it so the category does not look for an image?


Hi,

Can you provide link to that page?

timbrrr 04-17-2006 08:08 AM

Keep this one alive
 
anyone got this working on 4.1RC4 yet?

Dagobert 05-14-2006 01:12 AM

I tried all that to get it working under 4.1.0; but it always looks strange (no icons, and YES! I replaced di icon.php reference).

Anyone has it working under 4.1.0 ?


All times are GMT -8. The time now is 10:09 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.