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)
-   -   Automatically hiding blank extra fields (https://forum.x-cart.com/showthread.php?t=4589)

groovico 10-01-2003 09:22 PM

Automatically hiding blank extra fields
 
If you don't want extra fields to show up when they have no value (why would you...) then backup and replace your

/skin1/Modules/Extra_fields/Products.tpl with

Code:

{* $Id: product.tpl,v 1.0 2003 10 02  4:38:01 AP firetank Exp $ *}
{section name=field loop=$extra_fields}
{if $extra_fields[field].active eq "Y"}

{assign var="showthis" value="no"}
{if %field.index% eq 0}{if $product.param00 ne""}{assign var="showthis" value="yes"}{/if}
{elseif %field.index% eq 1}{if $product.param01 ne""}{assign var="showthis" value="yes"}{/if}
{elseif %field.index% eq 2}{if $product.param02 ne""}{assign var="showthis" value="yes"}{/if}
{elseif %field.index% eq 3}{if $product.param03 ne""}{assign var="showthis" value="yes"}{/if}
{elseif %field.index% eq 4}{if $product.param04 ne""}{assign var="showthis" value="yes"}{/if}
{elseif %field.index% eq 5}{if $product.param05 ne""}{assign var="showthis" value="yes"}{/if}
{elseif %field.index% eq 6}{if $product.param06 ne""}{assign var="showthis" value="yes"}{/if}
{elseif %field.index% eq 7}{if $product.param07 ne""}{assign var="showthis" value="yes"}{/if}
{elseif %field.index% eq 8}{if $product.param08 ne""}{assign var="showthis" value="yes"}}{/if}
{elseif %field.index% eq 9}{if $product.param09 ne""}{assign var="showthis" value="yes"}{/if}
{/if}

{if $showthis eq "yes"}
<tr><td width=30%>
{$extra_fields[field].field}</td>
</td>
<td>
{if %field.index% eq 0}{$product.param00}{elseif %field.index% eq 1}{$product.param01}{elseif %field.index% eq 2}{$product.param02}{elseif %field.index% eq 3}{$product.param03}{elseif %field.index% eq 4}{$product.param04}{elseif %field.index% eq 5}{$product.param05}{elseif %field.index% eq 6}{$product.param06}{elseif %field.index% eq 7}{$product.param07}{elseif %field.index% eq 8}{$product.param08}{elseif %field.index% eq 9}{$product.param09}{else}{/if}
</td>
</tr>
{/if}
{/if}
{/section}


This was tested with 3.4.5 - 3.4.8.

One day I'll understand why the extra field names aren't tied directly to paramXX fields by default since it's limited to 9 internally anyway... 8O

If anyone has a better way of doing the above without changing the php file (i.e using smarty to do it) please post it. I couldn't (be bothered :lol: ) to find a way to build the param0X name dynamically in smarty so I could loop through it :?

funkydunk 10-02-2003 05:25 AM

it works and thats the main thing :)

PhilJ 10-02-2003 12:16 PM

Thanks, good mod, ought to be standard :lol:

adpboss 10-06-2003 07:51 PM

Doesn't work so good in 3.3.8.

Useful but this mod made me realise that I don't need the extra fields. They are just more clutter on the product screen. 8)


All times are GMT -8. The time now is 05:20 PM.

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