X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Multi-column subcategories for 4.1.x (https://forum.x-cart.com/showthread.php?t=41422)

Ene 07-29-2008 06:25 AM

Multi-column subcategories for 4.1.x
 
Multi-column subcategories for 4.1.x


Edit the skin1/customer/main/subcategories.tpl template and replace:

PHP Code:

{if $subcategories}
<
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>
{/if} 



with the

PHP Code:

{if $subcategories}
<
table cellspacing="5" width="100%">
{
php}
$this->_tpl_vars['tmp_subcategories'] = array_values($this->_tpl_vars['subcategories']);
{/
php}
{
assign var=cols value="4"}
{
section name=tr loop=$tmp_subcategories step=$cols}
<
tr>
{
section name=td start=$smarty.section.tr.index loop=$smarty.section.tr.index+$cols}
<
td>
{if 
$tmp_subcategories[td].categoryid ne ""}
<
div align="center">
<
a href="home.php?cat={$tmp_subcategories[td].categoryid}">
<
img src="{if $tmp_subcategories[td].icon_url}{$tmp_subcategories[td].icon_url}{else}{$xcart_web_dir}/image.php?id={$tmp_subcategories[td].categoryid}&amp;type=C{/if}" alt="" /></a><br /><a href="home.php?cat={$tmp_subcategories[td].categoryid}">
<
font class="ItemsList">
{
$tmp_subcategories[td].category|escape|default:"&nbsp;"}
</
font>
</
a>
</
div>
{else}
&
nbsp;
{/if}
</
td>
{/
section}
</
tr>
{/
section}
</
table>
{/if} 


tricked 07-31-2008 01:16 AM

Re: Multi-column subcategories for 4.1.x
 
Thanks works great, any way to display the number of items in the subcatergories under the name

sorry im a newbie

Ene 07-31-2008 02:30 AM

Re: Multi-column subcategories for 4.1.x
 
Add this code:

PHP Code:

{if $tmp_subcategories[td].product_count}<br />({$tmp_subcategories[td].product_count } {$lng.lbl_products})
{elseif 
$tmp_subcategories[td].subcategory_count}<br />
({ 
$tmp_subcategories[td].subcategory_count } {$lng.lbl_categories|lower}
{/if}) 


below this line:

PHP Code:

{$tmp_subcategories[td].category|escape|default:"&nbsp;"


betty4 08-06-2008 04:37 PM

Re: Multi-column subcategories for 4.1.x
 
This code looks good and I like the 4-column presentation. What code would show the icon for the sub-category? It shows the default "no available image" icon even though there is an uploaded icon. X-Cart version 4.0.17

Ene 08-07-2008 04:27 AM

Re: Multi-column subcategories for 4.1.x
 
Quote:

What code would show the icon for the sub-category? It shows the default "no available image" icon even though there is an uploaded icon. X-Cart version 4.0.17

Replace this line

PHP Code:

{$xcart_web_dir}/image.php?id={$tmp_subcategories[td].categoryid}&amp;type=


with the

PHP Code:

{$xcart_web_dir}/icon.php?categoryid={$tmp_subcategories[td].categoryid


betty4 08-07-2008 12:01 PM

Re: Multi-column subcategories for 4.1.x
 
I'd like to add that one could add a css line for image to remove or pretty up the defaulted border as the stylesheet may not account for this.

Add this line to the style.css:

Quote:

img { border: none; }

betty4 08-07-2008 12:12 PM

Re: Multi-column subcategories for 4.1.x
 
Ene,

Bingo! That did the trick. I added a line to css to remove defaulted border. Beautiful.

BTW: What is the function of the type=C, $tmp_ , [td]? I've seen other image/icon/logo forum questions where intended images show up in some templates and only "no image available" in others. I think I may be able to solve the riddle with a little thinking person's experimentation.


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

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