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)
-   -   Not diplaying extra fields in certain instances (https://forum.x-cart.com/showthread.php?t=24169)

alan_ 08-17-2006 08:26 AM

Not diplaying extra fields in certain instances
 
I am using 2 extra fields for my products, but not every product is going to use the extra fields.

I would like to style the table that the extrafields are displayed in, but the problem is, I don't want the table to be displayed if the product isn't using the extrafields.

For example, if Product X is using at least 1 of the extra fields, then the styled table along with the extra field information is displayed on the product page. If Product Y is not using any of the extra fields then the styled table is not displayed.

Does anyone have any ideas on how this can be accomplished, or if it can be accomplished?

jdiehl 08-17-2006 08:53 AM

Look at the code that displays the extra fields. It will use some sort of loop that runs through the variables and displays the title and value of each extra field stored for the products.

All you need to do is run an if statement to see if there is a value in the extra field first before displaying it. no value no display

alan_ 08-17-2006 10:49 AM

I had tried that, but the table is going to have a header, and footer with the two extra fields in between. If there aren't values for the extra fields, the table rows and cells won't display, but the header and footer will still display. I want to keep from having the whole table from being displayed if there are no values set for the extra fields.

burtsTechie 09-19-2006 07:19 AM

Re: Not diplaying extra fields in certain instances
 
Alan- not sure if you got this figured out, but here's my solution to the same issue:

Code:

{* $Id: product.tpl,v 1.9 2005/11/21 12:42:06 max Exp $ *}

{section name=field loop=$extra_fields}
{if $extra_fields[field].active eq "Y" && $extra_fields[field].field_value}
{if $firstPass ne 1}
<table width="100%" cellpadding="0" cellspacing="0">
    <tr>
        <td colspan="2">
            <b><font class="ProductDetailsTitle">details</font></b>
        </td>
    </tr>
    <tr>
        <td class="Line" height="1" colspan="2"><img src="{$ImagesDir}/spacer.gif" class="Spc" alt="" /></td>
    </tr>
    <tr><td colspan="2">&nbsp;</td></tr>
    {assign var="firstPass" value="1"}
    {/if}
    <tr>
        <td width="30%">{$extra_fields[field].field}</td>
        {include file="milk_type_thumbnail.tpl"}
    </tr>
{/if}
{/section}

{if $firstPass eq 1}
</table>
<p />
{/if}


I wanted the extra fields to be in their own table in the main product.tpl page, but didn't want that table to show up if no extra fields were present. This 'product.tpl' page is in the modules/extra_fields folder!


All times are GMT -8. The time now is 01:23 AM.

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