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)
-   -   Centering Subcategories (https://forum.x-cart.com/showthread.php?t=55492)

Sisom 09-12-2010 06:01 AM

Centering Subcategories
 
Hi, I've been trying to center the Subcategories that are on this site which I am working on:

http://88.208.205.21/home.php?shopkey=martin
and then go to:
http://88.208.205.21/home.php?cat=253

for an example.

I edited customer/main/subcategories_t.tpl as follows (the added parts are in red):

Code:

{*
$Id: subcategories_t.tpl,v 1.7.2.2 2009/12/07 12:58:11 aim Exp $
vim: set ts=2 sw=2 sts=2 et:
*}

{section name=subcat_num loop=$subcategories}
{ if %subcat_num.first% }
<table border="0" cellspacing="5" width="100%">
{/if}

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


<td align="center">

{foreach from=$subcategories item=subcategory}
  <span class="subcategories" style="min-width: {$subcat_div_width+2}px; width: {$subcat_div_width}px; min-height: {$subcat_div_height}px;">
    {if $subcategory.is_icon}
      <a href="home.php?cat={$subcategory.categoryid}"><img src="{$subcategory.icon_url|amp}" alt="{$subcategory.category|escape}" width="{$subcategory.image_x}" height="{$subcategory.image_y}" /></a>
    {else}
      <img src="{$ImagesDir}/spacer.gif" alt="" width="1" height="{$subcat_img_height}" />
    {/if}

    <p><a class="subcat_desc" href="home.php?cat={$subcategory.categoryid}">{$subcategory.category|escape}</a></p>
   
 {if $config.Appearance.count_products eq "Y"}
      {if $subcategory.product_count}{$subcategory.product_count}&nbsp;{$lng.lbl_product}{if $subcategory.product_count > 1}s{/if}{/if}
    {elseif $subcategory.subcategory_count}
{$subcategory.subcategory_count}{if $subcategory.subcategory_count = 1}{$lng.lbl_subcategory}{elseif $subcategory.subcategory_count > 1}{$lng.lbl_subcategories}{/if}
    {/if}
    </span>
{/foreach}


</td>
{ if %subcat_num.last% }
</tr></table><br>
{/if}
{/section}


<div class="clearing"></div>
<br />


All the code in black is the original code.
The code I have added makes the page display the subcategories twice if there are two, or three times if there are three, etc.
I know that it needs to display all the subcategories, and I presume it comes from this code:
{foreach from=$subcategories item=subcategory}

but can anybody help me to fix this? All I want was to centre the subcategories, so that they appear like the related products, for example:

http://88.208.205.21/product.php?productid=17514&cat=262&page=1

retrtrtrytrutru 09-13-2010 01:39 AM

Re: Centering Subcategories
 
Not sure I understand your problem but you have declared that the table has a width of 100%. This makes it impossible for it to be centered. You could try removing the width declaration and just add a center declaration:

Code:

<center><table border="0" cellspacing="5">

...

</tr></table></center><br>


Sisom 09-13-2010 11:59 AM

Re: Centering Subcategories
 
I wanted to make the subcategory boxes appear centred within their cells, i.e. if there was only subcategory, it would only have one table cell, and would appear centred in that, if there were two subcategories, they would appear to be spaced equally horizontally, etc. I don't want to centre the entire table itself.
Using the code I added (which I took from the modified version of modules/Recommended_Products/recommends.tpl which I have uploaded to Completed Mods) I wanted to lay out the subcategory images in the same way as you see in the Related Products on the website.


All times are GMT -8. The time now is 02:01 PM.

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