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)
-   -   Displaying a single custom field on product page (https://forum.x-cart.com/showthread.php?t=41168)

John Livesey 07-17-2008 05:17 AM

Displaying a single custom field on product page
 
Hi all,

Is it possible to display a single custom field (rather than the whole array) when placed on the main product page?

Currently X-Cart displays all fields in one go in one area. I want to be able to display just one or two single fields (eg "On Sale" or "New Product") in a separate location to the rest of the custom fields.

What would the code be to achieve this please?

Thanks in advance
John

Thedae2k 07-21-2008 08:33 AM

Re: Displaying a single custom field on product page
 
You could use the "Extra Fields" feature of a provider.

toltion 08-06-2008 10:35 AM

Re: Displaying a single custom field on product page
 
You can display a single Extra Field value in the product page using the following code (works in 4.1.9).

{if $extra_fields.5.field_value ne ""}{$extra_fields.5.field_value}{/if}


The number '5' in the code specifies the index value of the Extra Field. To find this value, go to the Modify Product page in admin, view the "source" HTML of the page and scroll down to the extra fields. Look for name="efields[6]" and subtract 1 from the number displayed. The index is one less than the number of the Extra Field.

ChristineP 01-26-2009 08:59 AM

Re: Displaying a single custom field on product page
 
This is more what I need on my product.tpl page. I tried adding this to my product page, but it doesn't reference my specified extra field (ie. {if $extra_fields.6.field_value ne ""}{$extra_fields.6.field_value}{/if} ). I also tried this again after I disabled:
{if $active_modules.Extra_Fields ne ""}
{include file="modules/Extra_Fields/product.tpl"}
{/if}

then all the extra fields went away. Any suggestions to call out specific extra fields so I can place them on my product.tpl page?

Christine

Quote:

Originally Posted by toltion
You can display a single Extra Field value in the product page using the following code (works in 4.1.9).

{if $extra_fields.5.field_value ne ""}{$extra_fields.5.field_value}{/if}


The number '5' in the code specifies the index value of the Extra Field. To find this value, go to the Modify Product page in admin, view the "source" HTML of the page and scroll down to the extra fields. Look for name="efields[6]" and subtract 1 from the number displayed. The index is one less than the number of the Extra Field.


nivag 01-26-2009 09:20 AM

Re: Displaying a single custom field on product page
 
I am also having this same problem - I would like it to only show the extra fields with data in it... if its a blank field then dont display it.... anyone got this to work yet ?

toltion 01-26-2009 11:18 AM

Re: Displaying a single custom field on product page
 
I find it's best to call the Extra field by it's name, not it's index. The index can change as you add/delete extra fields. Here's a sample of what I use and it works fine for me. The Name of my extra field is "No Ship AIR?" -

Code:

        {section name=field loop=$extra_fields}
        {if $extra_fields[field].field eq "No Ship AIR?"}
        {if $extra_fields[field].field_value ne ""}{$extra_fields[field].field_value}{/if}
        {/if}
        {/section}


ChristineP 01-26-2009 12:10 PM

Re: Displaying a single custom field on product page
 
Awesome! I got this working for one of my extra fields by using the method you posted to call the extra field by it's name. Can you direct me to where I can find how to call out other extra fields from the same modules/Extra_Fields/product.tpl ?

This is what I used in my customer/main/product.tpl to capture the field name:
{if $active_modules.Extra_Fields ne ""}{$product.extra_fields.Manual.value}
{include file="modules/Extra_Fields/product.tpl"}
{/if}

Christine

Quote:

Originally Posted by toltion
I find it's best to call the Extra field by it's name, not it's index. The index can change as you add/delete extra fields. Here's a sample of what I use and it works fine for me. The Name of my extra field is "No Ship AIR?" -

Code:

        {section name=field loop=$extra_fields}
        {if $extra_fields[field].field eq "No Ship AIR?"}
        {if $extra_fields[field].field_value ne ""}{$extra_fields[field].field_value}{/if}
        {/if}
        {/section}




All times are GMT -8. The time now is 02:04 PM.

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