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

Can't get extra fields to show in other places

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 05-29-2009, 03:59 AM
 
Gibson1957 Gibson1957 is offline
 

Member
  
Join Date: Mar 2009
Posts: 23
 

Default Can't get extra fields to show in other places

Hi - I'm trying to get an extra field of "Product size" which we've added to show up in the products_t.tpl where we have a list of products, however I can't get it to show.
The code I added in was the bit inbetween the "size field" comment


{foreach from=$row item=product}
{if $product}
<td class="product-cell">
Size will go here
{* ************************ Size Field ************************ *}
{if $active_modules.Extra_Fields}

{foreach from=$extra_fields item=v}
{if $v.active eq "Y" && $v.field_value && $v.field == "Product size"}
TESTING
{$v.field_value}
{/if}
{/foreach}
{/if}
{* ************************************************** ************ *}
<div class="image">
<a href="product.php?productid={$product.productid}&c at={$cat}&page={$navigation_page}">{include file="product_thumbnail.tpl" productid=$product.productid image_x=$product.tmbn_x image_y=$product.tmbn_y product=$product.product tmbn_url=$product.tmbn_url}</a>

etc. etc. ....................................

It's showing "Size will go here" but not "TESTING" which is weird - I'm guessing it's not showing the size because maybe it doesn't have the product ID at that point to cross-reference in the "extra fields" list to get that value (need help with this) but interestingly it isn't showing the word "TESTING" either which suggests it isn't looping through the extra fields at all.......

Can anyone give me a hand with this?
__________________
X-Cart Gold 4.2

Add-on: X-Affiliate
Add-on: X-RMA (Return Merchandise Authorization)
Add-on: X-SpecialOffers
Add-on: X-AOM (Advanced Order Management)
Reply With Quote
  #2  
Old 05-30-2009, 10:25 AM
  gb2world's Avatar 
gb2world gb2world is offline
 

X-Wizard
  
Join Date: May 2006
Location: Austin, TX
Posts: 1,970
 

Default Re: Can't get extra fields to show in other places

To debug - you can print out the values of $v.active, $v.field_value and $v.field before you go into the if statement. You can see if they are as you expect.

Also, note there is a difference between $v.value and $v.field_value

You can use this tip to always see the variable values, to make sure they are what you think.
__________________
X-CART (4.1.9,12/4.2.2-3/4.3.1-2/4.4.1-5)-Gold
(CDSEO, Altered-Cart On Sale, BCSE Preorder Backorder, QuickOrder, X-Payments, BCSE DPM Module)
Reply With Quote

The following user thanks gb2world for this useful post:
Gibson1957 (07-01-2009)
  #3  
Old 06-04-2009, 01:57 AM
 
Gibson1957 Gibson1957 is offline
 

Member
  
Join Date: Mar 2009
Posts: 23
 

Default Re: Can't get extra fields to show in other places

Thanks for that - using it as a guide I managed to work out what was wrong.....
I think a lot of it was to do with the difference between the $v.value and $v.field_value thing........
__________________
X-Cart Gold 4.2

Add-on: X-Affiliate
Add-on: X-RMA (Return Merchandise Authorization)
Add-on: X-SpecialOffers
Add-on: X-AOM (Advanced Order Management)
Reply With Quote
  #4  
Old 07-23-2009, 01:15 PM
 
moomal moomal is offline
 

Advanced Member
  
Join Date: Apr 2009
Posts: 98
 

Default Re: Can't get extra fields to show in other places

Do you mind sharing the code you eventually used to get this to work? I'm using 4.2 and just cannot get extra fields to show up on products_t.tpl.
__________________
X-Cart Gold 4.2.0
Reply With Quote
  #5  
Old 07-23-2009, 11:56 PM
 
Gibson1957 Gibson1957 is offline
 

Member
  
Join Date: Mar 2009
Posts: 23
 

Default Re: Can't get extra fields to show in other places

{foreach from=$product.extra_fields item=v}
{if $v.active eq "Y" && $v.value ne "" && $v.field eq "*** Whatever your field is called ***"}
<span class="*** Whatever you want (style sheet) ***">{$v.value}</span>
{/if}
{/foreach}

For example your product field may be called "Size" etc. etc. - this code goes in the

{foreach from=$row item=product}
{if $product}

loop.

Hope that helps. Obviously if you're showing all the extra fields, you would omit the part that says '&& $v.field eq " blah blah " ' to show all of them.
__________________
X-Cart Gold 4.2

Add-on: X-Affiliate
Add-on: X-RMA (Return Merchandise Authorization)
Add-on: X-SpecialOffers
Add-on: X-AOM (Advanced Order Management)
Reply With Quote
  #6  
Old 07-24-2009, 09:44 AM
 
moomal moomal is offline
 

Advanced Member
  
Join Date: Apr 2009
Posts: 98
 

Default Re: Can't get extra fields to show in other places

Sorry to keep bothering you, but I still can't get it to work - did you have to edit products.php or any other PHP files to get extra fields to work on your products_t.tpl? If yes, do you remember what changes you made?
__________________
X-Cart Gold 4.2.0
Reply With Quote
  #7  
Old 01-09-2010, 09:02 AM
  proboscidian's Avatar 
proboscidian proboscidian is offline
 

Senior Member
  
Join Date: May 2005
Location: Clearwater, FL
Posts: 146
 

Default Re: Can't get extra fields to show in other places

To get it to work, you need to enclose it in the {foreach from=$row item=product}
{if $product} loop. Here's what I have in products_t.tpl to show any extra field that has a value:
Code:
<tr{interline name=products_matrix}> {foreach from=$row item=product name=products} {if $product} <td{interline name=products additional_class="product-cell"} style="width: {$cell_width}%;"> {foreach from=$product.extra_fields item=v} {if $v.active eq "Y" && $v.value ne ""} <span class="">{$v.field}: {$v.value}</span><br /> {/if} {/foreach} </td> {/if} {/foreach} </tr>
You don't need to make any changes in the php files. I did this in 4.3. There may be some unnecessary things in there; I just copied the loop from another loop (for product name) so there may be some bits that only belong there, but it does work.
__________________
Industrial Webworks
Various xcart versions from 4.1.19 gold - 4.7 gold
http://www.industrialwebworks.net
Reply With Quote
  #8  
Old 05-12-2010, 05:05 PM
 
TheWrongGrape TheWrongGrape is offline
 

Advanced Member
  
Join Date: Nov 2002
Location: Los Angeles, CA
Posts: 68
 

Default Re: Can't get extra fields to show in other places

Quote:
Originally Posted by proboscidian
You don't need to make any changes in the php files. I did this in 4.3. There may be some unnecessary things in there; I just copied the loop from another loop (for product name) so there may be some bits that only belong there, but it does work.

Been trying to get extra fields to show up in my products list (products_list.tpl) in 4.3.1 with no luck. Tried your suggestion but nothing happens. The search continues.


Edit: Got it working now: http://forum.x-cart.com/showpost.php?p=287479&postcount=10
Reply With Quote
  #9  
Old 10-21-2010, 07:25 AM
  RedandBlue's Avatar 
RedandBlue RedandBlue is offline
 

Senior Member
  
Join Date: Aug 2009
Posts: 170
 

Exclamation Re: Can't get extra fields to show in other places

trying same for 4.3.2
no use
__________________
rbgx
X-Cart 4.3.2
Reply With Quote
  #10  
Old 08-22-2011, 01:53 PM
 
obaluba2 obaluba2 is offline
 

Senior Member
  
Join Date: Sep 2006
Posts: 152
 

Default Re: Can't get extra fields to show in other places

did anyone get this working with 4.3.2?
__________________
4.0.1.18 & 4.1.6 & 4.1.9 & 4.1.11 & 4.2.2 & 4.3.2, 4.6.1
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 08:57 PM.

   

 
X-Cart forums © 2001-2020