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)
-   -   Display Sub Categories in 2 or 3 column + Pic (https://forum.x-cart.com/showthread.php?t=40023)

chealyte 05-25-2008 03:43 PM

Display Sub Categories in 2 or 3 column + Pic
 
I am wondering does anyone done this yet or know how to do this ?..

I want to display my sub-Categories in 2 or 3 column with catagory picture infront of each one name .. i am wondering how do it this ?

example :

Cat-Pic 1 : Cat name 1 | Cat-Pic 2 : Cat Name 2 | Cat-pic 2 : Cat name 2
Cat-Pic 4 : Cat name 4 | Cat-Pic 5 : Cat Name 5 | Cat-pic 6 : Cat name 6

Thank in advance for help

xim 05-26-2008 06:29 AM

Re: Display Sub Categories in 2 or 3 column + Pic
 
Try to use the following code in the template where the $subcategories array is defined:

Code:

{assign var="cell_counter" value="0"}
{assign var="subcat_per_row" value="3"}

<table width="100%" cellspacing="5">
{foreach from=$subcategories item=subcat}
{math equation="x+1" x=$cell_counter assign="cell_counter"}
{if $cell_counter eq "1"}<tr>{/if}
<td><a href="home.php?cat={$subcat.categoryid}"><img src="{$subcat.categoryid|func_get_image_url:C|default:"image.php?id=`$subcat.categoryid`&type=C"}" alt="{$subcat.category|escape}" style="padding-right: 5px;" align="left"/>{$subcat.category}</a></td>

{if $cell_counter eq $subcat_per_row}
    </tr>
    {assign var="cell_counter" value="0"}
{/if}
{/foreach}
{if $cell_counter gt 0}
{section loop=$subcat_per_row name=cc start=$cell_counter}
<td>&nbsp;</td>
{/section}
</tr>
{/if}
</table>


Also, I'd recommend you to move your category images to the file system. You can perform it under admin area on the "Images location" page.

chealyte 05-26-2008 02:24 PM

Re: Display Sub Categories in 2 or 3 column + Pic
 
i found " subcategories.tpl " but it is look like not the place where $subcategories is define .. and it is a lot files to look into .. BUT .. if we assignt this to file where " $subcategories " is define will it effect the menu system ? i saw it use " $subcategories " too.

xim 05-26-2008 09:25 PM

Re: Display Sub Categories in 2 or 3 column + Pic
 
This code should work on the categories pages, products listing and product details page.

On these pages you can use this code in any templates which are included to show the appropriate content.

chealyte 06-05-2008 04:24 PM

Re: Display Sub Categories in 2 or 3 column + Pic
 
can i know which file(s) exacly that i should modify and add the code to it ?

xim 06-05-2008 09:45 PM

Re: Display Sub Categories in 2 or 3 column + Pic
 
Quote:

Originally Posted by chealyte
can i know which file(s) exacly that i should modify and add the code to it ?


Generally the subcategories list on the category details page. Therefore you should edit the "skin1/customer/main/subcategories.tpl" template as you previously did it.

If you have any problem with code implementing I'd recommend you to contact your Support team in your Help Desk account.

Yurij 06-06-2008 04:42 AM

Re: Display Sub Categories in 2 or 3 column + Pic
 
Quote:

Originally Posted by chealyte
can i know which file(s) exacly that i should modify and add the code to it ?


"skin1/customer/main/subcategories.tpl"

Find in the file the following code and replace at that what you wrote above.

PHP Code:

.......
<
table cellspacing="5" width="100%">
{foreach 
from=$subcategories item=subcat}
<
tr>
{if 
$tmp and $first_subcat ne "Y"}
    <
td valign="top" rowspan="{count value=$subcategories print="Y"}"><img src="{if $current_category.icon_url}{$current_category.icon_url}{else}{$xcart_web_dir}/image.php?id={$cat}&amp;type=C{/if}" alt="" /></td>
{
assign var="first_subcat" value="Y"}
{/if}
    <
td class="SubcatTitle"><a href="home.php?cat={ $subcat.categoryid }"><font class="ItemsList">{ $subcat.category|escape }</font></a><br /></td>
    <
td class="SubcatInfo">{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>
</
tr>
{/foreach}
</
table>
....... 



All times are GMT -8. The time now is 06:48 PM.

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