Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Multi-column subcategories for 4.1.x

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 07-29-2008, 06:25 AM
  Ene's Avatar 
Ene Ene is offline
 

X-Cart team
  
Join Date: Aug 2004
Posts: 907
 

Default 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} 
__________________
Eugene Kaznacheev,
Evangelist/Product Manager at Ecwid: http://www.ecwid.com/ (since Sept 2009)

ex-Head of X-Cart Tech Support Department
ex- X-Cart Hosting Manager - X-Cart hosting
ex-X-Cart Technical Support Engineer


Note: For the official guaranteed tech support services please turn to the Customers HelpDesk.
Reply With Quote
  #2  
Old 07-31-2008, 01:16 AM
 
tricked tricked is offline
 

Newbie
  
Join Date: Sep 2005
Location: Australia
Posts: 5
 

Default 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
__________________
X-Cart 4.4
Reply With Quote
  #3  
Old 07-31-2008, 02:30 AM
  Ene's Avatar 
Ene Ene is offline
 

X-Cart team
  
Join Date: Aug 2004
Posts: 907
 

Default 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;"
__________________
Eugene Kaznacheev,
Evangelist/Product Manager at Ecwid: http://www.ecwid.com/ (since Sept 2009)

ex-Head of X-Cart Tech Support Department
ex- X-Cart Hosting Manager - X-Cart hosting
ex-X-Cart Technical Support Engineer


Note: For the official guaranteed tech support services please turn to the Customers HelpDesk.
Reply With Quote
  #4  
Old 08-06-2008, 04:37 PM
  betty4's Avatar 
betty4 betty4 is offline
 

Advanced Member
  
Join Date: Aug 2006
Posts: 75
 

Question 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
__________________
Was 4.0.17 Gold w/3rd party modules
Now 4.5.5 Gold with core modules
Reply With Quote
  #5  
Old 08-07-2008, 04:27 AM
  Ene's Avatar 
Ene Ene is offline
 

X-Cart team
  
Join Date: Aug 2004
Posts: 907
 

Default 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
__________________
Eugene Kaznacheev,
Evangelist/Product Manager at Ecwid: http://www.ecwid.com/ (since Sept 2009)

ex-Head of X-Cart Tech Support Department
ex- X-Cart Hosting Manager - X-Cart hosting
ex-X-Cart Technical Support Engineer


Note: For the official guaranteed tech support services please turn to the Customers HelpDesk.
Reply With Quote
  #6  
Old 08-07-2008, 12:01 PM
  betty4's Avatar 
betty4 betty4 is offline
 

Advanced Member
  
Join Date: Aug 2006
Posts: 75
 

Post 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; }
__________________
Was 4.0.17 Gold w/3rd party modules
Now 4.5.5 Gold with core modules
Reply With Quote
  #7  
Old 08-07-2008, 12:12 PM
  betty4's Avatar 
betty4 betty4 is offline
 

Advanced Member
  
Join Date: Aug 2006
Posts: 75
 

Default 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.
__________________
Was 4.0.17 Gold w/3rd party modules
Now 4.5.5 Gold with core modules
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

   

 
X-Cart forums © 2001-2020