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)
-   -   Subcategory Rows Not Filled Properly (https://forum.x-cart.com/showthread.php?t=39109)

anela2003 04-15-2008 02:17 PM

Subcategory Rows Not Filled Properly
 
I have a question about proper formatting for my subcategory rows. I have used previous posts on this topic (although quite difficult to apply because they are old) to alter my subcategory templates. This was in January I believe.

Well, now that I have 10 subcategories within a subcategory itself, they are not displayed properly. Initially, I set up the layout to show 5 subcategories per row. But now, it shows 5 in row 1, 4 in row 2 and 1 in row 3 (instead of filling a row before starting a new one).

I'm guessing that it has to do with the "$tmp" in my subcategories.tpl, but I haven't been able to change it to what I want it to do.

Here's the problem page that doesn't fill the rows completely:

Custom Valances



And here's my subcategories.tpl:
HTML Code:

{* $Id: subcategories.tpl,v 1.43.2.9 2006/06/27 08:22:01 svowl Exp $ *}

{if ($navigation_page eq "")||($navigation_page eq "1")}{$current_category.description}<BR><BR>{/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}
{if $subcategories}
<table class="sublisttable">






<tr>
{foreach from=$subcategories item=subcat}
{if $tmp is div by 4}
</tr>
<tr class="sublisttr">
{/if}

{ if $tmp and $first_subcat ne "Y" }
{assign var="tmp" value=0}
{assign var="first_subcat" value="Y"}
{/if}

<td class="subclist">
<a href="home.php?cat={ $subcat.categoryid }"><img src="{if $subcat.icon_url}{$subcat.icon_url}{else}{$xcart_web_dir}/default_image.gif{/if}" alt="Priority Windows Custom Products" width="150" height="150"><br>
<font class="ItemsList">{ $subcat.category|escape }</font><BR><img src="images/customize.png" width="150" height="25"></a>{if $config.Appearance.count_products eq "Y"}{/if}
{assign var="tmp" value=$tmp+1}
{/foreach}
</table>
{/if}
{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}
<BR>
{ include file="customer/main/navigation.tpl" }
{/if}
<BR>
{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 content=$smarty.capture.dialog
extra="width=100%"}
{if $products eq ""}
{if $f_products ne ""}
<P>
{include file="customer/main/featured.tpl"}
{/if}
{/if}
{ include file="customer/main/navigation.tpl" }




Thanks again!!! :mrgreen:

kube 04-15-2008 03:51 PM

Re: Subcategory Rows Not Filled Properly
 
Hi anela2003,

What about trying this below. Adapt where you see fit (I've removed a quite a bit of code as we're concentrating on the table itself and made it html valid in the process)...

Code:

{if $subcategories}
{assign var="items_per_row" value=5}
<table class="sublisttable">
<tr class="sublisttr">
{foreach from=$subcategories item=subcat name=loopy}
<td class="subclist">
<a href="home.php?cat={ $subcat.categoryid }"><img src="{if $subcat.icon_url}{$subcat.icon_url}{else}{$xcart_web_dir}/default_image.gif{/if}" alt="Priority Windows Custom Products" width="150" height="150" /><br />
<span class="ItemsList">{ $subcat.category|escape }</span><br /><img src="images/customize.png" width="150" height="25" alt="" /></a>
</td>
{if $smarty.foreach.loopy.iteration mod $items_per_row eq 0}
</tr><tr class="sublisttr">
{/if} 
{/foreach}
</tr>
</table>
{/if}


Hope this gets in you in the right direction.

anela2003 04-15-2008 11:33 PM

Re: Subcategory Rows Not Filled Properly
 
BEAUTIFUL!

Worked like a charm, thank you, thank you.


All times are GMT -8. The time now is 07:29 PM.

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