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

yuichi 05-12-2008 08:28 PM

Subcategory Icon
 
Hi All.
I am having a hard time figuring this out...
I was able to show the Subcategory Icon with this thread...
http://forum.x-cart.com/showthread.php?t=3848&page=22&highlight=subcategor ies+icons

Subcategory Icon shows on the Category page with bunch of Subcategory icons, but when I click on the specific Subcategory to go to that Subcategory page, then icon dissapears.

I added
Code:

<img src="{$subcat.icon_url}" alt="" />

at the beginning of the subcategories.tpl , but no luck..

Any help much appreciated....

Yurij 05-13-2008 12:30 AM

Re: Subcategory Icon
 
Quote:

Originally Posted by yuichi
Hi All.
I am having a hard time figuring this out...
I was able to show the Subcategory Icon with this thread...
http://forum.x-cart.com/showthread.php?t=3848&page=22&highlight=subcategor ies+icons

Subcategory Icon shows on the Category page with bunch of Subcategory icons, but when I click on the specific Subcategory to go to that Subcategory page, then icon dissapears.

I added
Code:

<img src="{$subcat.icon_url}" alt="" />

at the beginning of the subcategories.tpl , but no luck..

Any help much appreciated....



Try used this code for subcategories.tpl.

Option:
{assign var="count_per_row" value=3} (3 - count column)
<img src="{$c.icon_url}" width=200> (200px - image width)


PHP Code:

{if $active_modules.Bestsellers ne "" and $config.Bestsellers.bestsellers_menu ne "Y"}
<
/>
{include 
file="modules/Bestsellers/bestsellers.tpl"}
{/if}
<
/>
{if 
$active_modules.Special_Offers}
{include 
file="modules/Special_Offers/customer/category_offers_short_list.tpl"}
{/if}
{if (
$navigation_page eq "")||($navigation_page eq "1")}{$current_category.description}</>{/if}
{
capture name=dialog}
{
assign var="tmp" value="0"}
{foreach 
from=$subcategories item=c key=catid}
{if 
$c.category}{assign var="tmp" value="1"}{/if}
{/foreach}
{if 
$subcategories}
<
table   width="100%">
{
assign var="count_per_row" value=3}

{
math equation="floor(100/x)" x=$count_per_row assign="width"}
{
assign var="count" value=0}

{foreach 
from=$subcategories item=c key=catid}

        {if 
$count is div by $count_per_row}
            <
tr>
            {
assign var="count" value=0}
        {/if}

        <
td align=center valign=top>

        <
table border=0>
            <
tr>
                <
td align=center valign=top><a href="home.php?cat={$catid}class="VertMenuItems">
                {if 
$c.icon_url ne ""}<img src="{$c.icon_url}width=200>
                {else}
                <
img src="image.php?type=C&id=0&ts=" width=125>                
                {/if}</
a></td>
            <
tr>
            <
tr>
                <
td align=center><font class="CategoriesList"><a href="home.php?cat={$catid}class="VertMenuItems">{$c.category}</a></font></td>
            </
tr>
            {*<
tr>
                <
td align=center>{$c.description}</td>
            <
tr>*}

        </
table>

        </
td>

        {
capture name=prod_index}
            {
math equation="index+x+1" index=$count x=$count_per_row}
        {/
capture}
        
        {if 
$smarty.capture.prod_index is div by $count_per_row}
            </
tr>
        {/if}
        {
math equation="x+1" x=$count assign="count" }

{/foreach}

    {if 
$count lt $count_per_row}
    {
section name=rest_cells loop=$count_per_row start=$count}
        <
td class="SectionBox">&nbsp;</td>
    {/
section}
    {/if}
</
tr>
 
</
table>
{/if}
{if 
$tmp and $products ne "" }
<
br clear="left" />
<
hr size="1" noshade="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}
<
hr size="1" width="100%" />
{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 ""}
<
/>
{include 
file="customer/main/featured.tpl"}
{/if}
{/if}
{ include 
file="customer/main/navigation.tpl" 


yuichi 05-13-2008 06:48 PM

Re: Subcategory Icon
 
Yurij, Thanks for your kind reply.
I actually was able to show subcategory icons with 3 columns in the main category page.
What I want to do is to place a subcategory icon at the beginning of the page right before the subcategory description.
I've been trying to do this for a while, but no luck at all..

Yurij 05-14-2008 07:43 AM

Re: Subcategory Icon
 
Quote:

Originally Posted by yuichi
Yurij, Thanks for your kind reply.
I actually was able to show subcategory icons with 3 columns in the main category page.
What I want to do is to place a subcategory icon at the beginning of the page right before the subcategory description.
I've been trying to do this for a while, but no luck at all..


With the flow around icons category or not?

If you're comment out 3 lines, you will be displayed the description category under of the icon category.

PHP Code:

.........
            {*<
tr>
                <
td align=center>{$c.description}</td>
            <
tr>*}
.....
.....
            <
tr>
                <
td align=center>{$c.description}</td>
            <
tr



Ups... I forgot one moment... ;)

Open file "include/categories.php" and find next line:

PHP Code:

if ($short_list) {
        
$to_search "$sql_tbl[categories].categoryid,$sql_tbl[categories].parentid,$sql_tbl[categories].categoryid_path,$sql_tbl[categories].category,$sql_tbl[categories].avail,$sql_tbl[categories].order_by";
    } else {
        
$to_search "$sql_tbl[categories].*";
    } 


And to replace those lines with this code

PHP Code:

if ($short_list) {
        
$to_search "$sql_tbl[categories].categoryid,$sql_tbl[categories].parentid,$sql_tbl[categories].categoryid_path,$sql_tbl[categories].category,$sql_tbl[categories].avail,$sql_tbl[categories].order_by, $sql_tbl[categories].description";
    } else {
        
$to_search "$sql_tbl[categories].*";
    } 


yuichi 05-14-2008 02:14 PM

Re: Subcategory Icon
 
Yurij,
I really appreciate your kind help. I was able to show the icons.

Here is the pic of it.

http://sauce-mania.com/00/p1.png



Now, how can I do this? This is on the page after you clicking on "Soy Sauce"...

http://sauce-mania.com/00/p2.png

Yurij 05-15-2008 12:30 AM

Re: Subcategory Icon
 
Open file "skin1/customer/main/subcategories.tpl", find next line:
PHP Code:

{if ($navigation_page eq "")||($navigation_page eq "1")}{$current_category.description}</>{/if} 


And to replace those lines with this code

PHP Code:

{if ($navigation_page eq "")||($navigation_page eq "1")}
<
img src="{if $current_category.icon_url}{$current_category.icon_url}{else}{$xcart_web_dir}/image.php?id={$cat}&amp;type=C{/if}" alt="" />
{
$current_category.description}</>{/if} 


yuichi 05-15-2008 08:17 PM

Re: Subcategory Icon
 
Yurij,

YOU ARE DA MAN! Thank you very much! It all worked great!!!!!!!!!!!!!!
Thank You!

Mikenotmike 05-15-2008 09:35 PM

Re: Subcategory Icon
 
That's amazing... I spent all night trying every solution on this board, gave up to try again tonight and the answer was posted while I slept.

I love you

4.1.9

ladybird 08-06-2009 04:41 AM

Re: Subcategory Icon
 
I have successfully modified tthe sub cat template to enable icons to appear but they blow out - is there a way to limit the icon size?

Thanks

L

pia 05-03-2010 04:45 PM

Re: Subcategory Icon - 4.3.1
 
Hi

I just wanted to let people know that the code posted in #2 of this thread by yurij works fine in 4.3.1 . I added a style class to the table call to add a border and further styling and it was perfect! 3 columns of subcats displayed just how i like it :-)

cosy 05-04-2010 10:01 PM

Re: Subcategory Icon
 
HI, Can you please share your code with us?Thanks

pia 05-04-2010 10:22 PM

Re: Subcategory Icon
 
1 Attachment(s)
No problem,

In customer/main/subcategories.tpl I have the following:

Code:

{if $active_modules.Bestsellers ne "" and $config.Bestsellers.bestsellers_menu ne "Y"}
<p />
{include file="modules/Bestsellers/bestsellers.tpl"}
{/if}
<p />
{if $active_modules.Special_Offers}
{include file="modules/Special_Offers/customer/category_offers_short_list.tpl"}
{/if}
{if ($navigation_page eq "")||($navigation_page eq "1")}{$current_category.description}<p />{/if}
{capture name=dialog}
{assign var="tmp" value="0"}
{foreach from=$subcategories item=c key=catid}
{if $c.category}{assign var="tmp" value="1"}{/if}
{/foreach}
{if $subcategories}
<table  width="100%">
{assign var="count_per_row" value=3}

{math equation="floor(100/x)" x=$count_per_row assign="width"}
{assign var="count" value=0}

{foreach from=$subcategories item=c key=catid}

        {if $count is div by $count_per_row}
            <tr>
            {assign var="count" value=0}
        {/if}

        <td align=center valign=top>
<div class="subcatrow">
        <table border=0 class="subcatstyle" cellspacing="0">
            <tr>
                <td align="center" valign="top" ><a href="home.php?cat={$catid}" class="VertMenuItems">
                {if $c.icon_url ne ""}<img src="{$c.icon_url}" width=120>
                {else}
                <img src="image.php?type=C&id=0&ts=" width=105>               
                {/if}</a></td>
            </tr>
            <tr>
                <td align="center"><font class="CategoriesList"><a href="home.php?cat={$catid}" class="VertMenuItems">{$c.category}</a></font></td>
            </tr>
            {*<tr>
                <td align=center>{$c.description}</td>
            <tr>*}

        </table>
</div>
        </td>

        {capture name=prod_index}
            {math equation="index+x+1" index=$count x=$count_per_row}
        {/capture}
       
        {if $smarty.capture.prod_index is div by $count_per_row}
            </tr>
        {/if}
        {math equation="x+1" x=$count assign="count" }

{/foreach}

    {if $count lt $count_per_row}
    {section name=rest_cells loop=$count_per_row start=$count}
        <td class="SectionBox">&nbsp;</td>
    {/section}
    {/if}
</tr>
 
</table>
{/if}
{if $tmp and $products ne "" }
<br clear="left" />
<hr size="1" noshade="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}
<hr size="1" width="100%" />
{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" } 


Then, in your skin1/main.css I have the following style code that you can change and add to as fits your design:

[code]/* pia's subcat styles */
table.subcatstyle {
width: 150px; margin-right: 30px; margin-bottom: 10px;
}

.subcatrow {
height: 175px;
border: 1px solid #cccccc;
text-align: center;
padding-left: 15px;
vertical-align: middle;
}
/* end subcatstyles */

You can see what it looks like in the screen shot:Attachment 1934

I hope that helps

oh and ps... the sub cat image works for my css if its no bigger than 150 x 150 ish :)

cosy 05-04-2010 11:14 PM

Re: Subcategory Icon
 
Thank you so much, and do you got product under neath?

i'm trying to figure out when click the root menu it's only show the subcategory icons only so like to show some images under neath this sub cat icons?

pia 05-04-2010 11:32 PM

Re: Subcategory Icon
 
Hi cosy,

If your categories have no products in them that aren't in subcategories, then no products/images will show beneath the subcats.

Not sure I understood your question correctly, so is that what you were asking?

cosy 05-05-2010 04:53 AM

Re: Subcategory Icon
 
Quote:

Originally Posted by pia
Hi cosy,

If your categories have no products in them that aren't in subcategories, then no products/images will show beneath the subcats.

Not sure I understood your question correctly, so is that what you were asking?


I have a number of subcategories On the subcategories page, I would like to be able to show these subcategories like your box image.

also

When they do have products in them, they should be displayed on the same page.


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

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