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

Displaying a single custom field on product page

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 07-17-2008, 05:17 AM
 
John Livesey John Livesey is offline
 

Advanced Member
  
Join Date: May 2008
Posts: 33
 

Default 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
__________________
Version: 4.1.9
Reply With Quote
  #2  
Old 07-21-2008, 08:33 AM
 
Thedae2k Thedae2k is offline
 

eXpert
  
Join Date: Jan 2004
Posts: 288
 

Default Re: Displaying a single custom field on product page

You could use the "Extra Fields" feature of a provider.
__________________
X-Cart Pro 4.1.9
PHP5.2.5
MySQL 5.0.54
IIS/Apache/NGINX Webservers
Reply With Quote
  #3  
Old 08-06-2008, 10:35 AM
 
toltion toltion is offline
 

Advanced Member
  
Join Date: Jun 2007
Posts: 39
 

Default 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.
__________________
X-Cart Gold 4.1.9
Gift Registry/Special Offers
Advanced mini-cart
XC-SEO
Mulltiple Category/Product Templates
Also bought/recently viewed
Feedback reviewer/viewer bundle
Marketing Manager Pro bundle
many more mods
Reply With Quote

The following user thanks toltion for this useful post:
chamberinternet (01-18-2010)
  #4  
Old 01-26-2009, 08:59 AM
 
ChristineP ChristineP is offline
 

eXpert
  
Join Date: Jul 2008
Posts: 310
 

Default 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.
__________________
______________
version 4.1.9 Gold
Reply With Quote
  #5  
Old 01-26-2009, 09:20 AM
 
nivag nivag is offline
 

Advanced Member
  
Join Date: Oct 2008
Posts: 76
 

Default 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 ?
Reply With Quote
  #6  
Old 01-26-2009, 11:18 AM
 
toltion toltion is offline
 

Advanced Member
  
Join Date: Jun 2007
Posts: 39
 

Default 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}
__________________
X-Cart Gold 4.1.9
Gift Registry/Special Offers
Advanced mini-cart
XC-SEO
Mulltiple Category/Product Templates
Also bought/recently viewed
Feedback reviewer/viewer bundle
Marketing Manager Pro bundle
many more mods
Reply With Quote

The following user thanks toltion for this useful post:
carpeperdiem (03-05-2009)
  #7  
Old 01-26-2009, 12:10 PM
 
ChristineP ChristineP is offline
 

eXpert
  
Join Date: Jul 2008
Posts: 310
 

Default 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}
__________________
______________
version 4.1.9 Gold
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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 06:30 AM.

   

 
X-Cart forums © 2001-2020