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

Extra Fields 4.1.x products_t.tpl

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 09-21-2006, 12:47 PM
 
Cpt.Crashtastic Cpt.Crashtastic is offline
 

eXpert
  
Join Date: Jan 2006
Posts: 219
 

Default Extra Fields 4.1.x products_t.tpl

I sacrificed 25 points for the soloution as I couldn't get there myself. Thanks to the Xcart Team

By default, the extra field values are not assignd to the Smarty template engine on the products page (they are shown only on the product details page). In order to achieve such a functionality, the following modification to the 'products.php' file is required:

insert the next code
Code:
if (!empty($active_modules["Extra_Fields"]) && !empty($products)) { foreach($products as $k => $v) { $products[$k]["extra_fields"] = func_query("SELECT $sql_tbl[extra_fields].field as field, $sql_tbl[extra_field_values].value as value, $sql_tbl[extra_fields].service_name as service_name FROM $sql_tbl[extra_fields], $sql_tbl[extra_field_values] WHERE $sql_tbl[extra_field_values].fieldid = $sql_tbl[extra_fields].fieldid AND $sql_tbl[extra_fields].active='Y' AND $sql_tbl[extra_field_values].productid = '$v[productid]'"); } }

just before the following line:

$smarty->assign("products",$products);


Then extra fields will be assigned to the '/skin1/customer/main/products_t.tpl' Smarty template and you'll be able to operate with the values. For example, you may show all extra fields for the product if you insert the following code (into the '/skin1/customer/main/products_t.tpl' template)

{foreach from=$products[product].extra_fields item="ef"}
{if $ef.value ne ''}
<br>{$ef.field}: {$ef.value}
{/if}
{/foreach}


before the next one:

{if $active_modules.Feature_Comparison ne '' && $products[product].fclassid > 0}


If you need to display only certain extra field which has the 'minPrice' service name, then you are supposed to use the next code:

{foreach from=$products[product].extra_fields item="ef"}
{if $ef.value ne '' && $ef.service_name eq 'minPrice'}
<br>{$ef.field}: {$ef.value}
{/if}
{/foreach}

Hope that helps
__________________
Xcart 4.4.?
Xcart Next
Litecommerce with Drupal
http://www.corbywebworx.com

Custom Mods, Hosting and Support for Xcart-Next and LiteCommerce
Reply With Quote

The following user thanks Cpt.Crashtastic for this useful post:
chastie (03-29-2009)
  #2  
Old 09-21-2006, 12:58 PM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: Extra Fields 4.1.x products_t.tpl

Funny...there must be 500 posts asking for this functionality in 4.1 and it looks like it still isn't there by default
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #3  
Old 10-30-2006, 03:04 PM
 
HEK HEK is offline
 

Member
  
Join Date: Jul 2005
Posts: 23
 

Default Re: Extra Fields 4.1.x products_t.tpl

nn... it doesnt work...why??
I'm now using 4.1.3
Reply With Quote
  #4  
Old 01-11-2007, 11:49 AM
 
KeeYoung Hartley KeeYoung Hartley is offline
 

Newbie
  
Join Date: Nov 2004
Posts: 2
 

Default Re: Extra Fields 4.1.x products_t.tpl

I added the code

Code:
{foreach from=$products[product].extra_fields item="ef"} {if $ef.value ne ''} <br>{$ef.field}: {$ef.value} {/if} {/foreach}

into '/skin1/customer/main/products.tpl' instead of products_t.tpl and it works.

Thank you!
__________________
X-Cart Gold v4.1.3
Reply With Quote
  #5  
Old 01-26-2007, 11:24 AM
 
bradjd bradjd is offline
 

Advanced Member
  
Join Date: Jul 2004
Posts: 31
 

Default Re: Extra Fields 4.1.x products_t.tpl

Quick Comment:

Using the above mod you can also use the following to output a specified output

for values:
{$products[product].extra_fields[0].value}

for field titles:
{$products[product].extra_fields[0].field}

this is slightly different than the syntax for the product page variables

-Thanks for the contribution Cpt, saved me lots of time
__________________
Fruition
V - 3.5 - 4.1.5
Reply With Quote
  #6  
Old 01-29-2007, 04:43 AM
 
jhoyssa jhoyssa is offline
 

Newbie
  
Join Date: Sep 2006
Posts: 4
 

Default Re: Extra Fields 4.1.x products_t.tpl

Hi

Thanks for the post, this helped me to clear out the system a bit, but there's still something that I can't get to work.

Since I didn't have any service_name-column in the database (what's with that?) and I needed to check out the value regardless to the activity, I modified the lines suggested in the original post a bit and put them into my products.php:

Code:
if (!empty($active_modules["Extra_Fields"]) && !empty($products)) { foreach($products as $k => $v) { $products[$k]["extra_fields"] = func_query("SELECT $sql_tbl[extra_fields].field as field, $sql_tbl[extra_field_values].value as value FROM $sql_tbl[extra_fields], $sql_tbl[extra_field_values] WHERE $sql_tbl[extra_field_values].fieldid = $sql_tbl[extra_fields].fieldid AND $sql_tbl[extra_field_values].productid = '$v[productid]'"); } } $smarty->assign("products",$products);

This thing works like a charm on the customer/main/products.tpl and I can simply refer to the variable I need by using $products[product].extra_fields[8].value. Anyhow, I'd need the same information on the featured products-lists, but for some reason(s) all the extra fields are not to be used in customer/main/products_t.tpl, although the original posting suggests just that.

By putting the line
Code:
{$products[product].extra_fields|@debug_print_var
in the products_t.tpl it tells that the array is empty.

Trying everything, I gave
Code:
{$extra_fields|@debug_print_var}
a shot too, but it shows only three extra fields and their contents, but there are actually nine (and I'd need the last one of course ). Is there a LIMIT somewhere or what does this mean?

Did I mess up something when I modified the query-part in the products.php? Or should it be assigned also somewhere else to work in the products_t.tpl? The featured products list is used in multicolumn format.
__________________
Version 4.0.19
Reply With Quote
  #7  
Old 06-12-2007, 01:41 AM
  carlisleglass's Avatar 
carlisleglass carlisleglass is offline
 

eXpert
  
Join Date: Aug 2003
Location: Carlisle, UK
Posts: 316
 

Default Re: Extra Fields 4.1.x products_t.tpl

remove the following from the statement

AND $sql_tbl[extra_fields].active='Y'

and it will pick up all your extra fields not just the active ones (in other words the ones with the show box ticked).

You can also put the same statement in your featured_products.php so that extra fields are available to them as well.

UPDATE: add again the same coding into include/search.php just above $smarty->assign("products",$products); and you will have extra fields in your search results also.
__________________
Darren Kierman
Carlisle Glass (http://www.carlisleglass.co.uk/)
... running X-Cart Gold 4.4.5 [unix]
Reply With Quote
  #8  
Old 06-12-2007, 10:57 AM
  vtonya's Avatar 
vtonya vtonya is offline
 

Advanced Member
  
Join Date: Apr 2007
Posts: 61
 

Default Re: Extra Fields 4.1.x products_t.tpl

Carlisleglass, thanks, but i didn't understand.
Can you please write in advance what code should i add to the search.php or to some other files so it'll have extra fields in my search results also
__________________
X-card Gold 4.1.7
Batch Order Mod/Order Processing
Detailed Order Management Mod
Order Audit/Profit reports
Advanced Product Search
Ajax Username Checker
Direct Product Enquiry Form
FAQ Manager
Social Bookmarking
Tabs Mod v3
MagneticOne.com All-IN-ONE X-Cart Export
Show Referrer Information on Order Details Page
www.medsmarket.net
Reply With Quote
  #9  
Old 09-21-2007, 07:21 AM
 
spwestwood spwestwood is offline
 

Member
  
Join Date: Aug 2007
Posts: 17
 

Default Re: Extra Fields 4.1.x products_t.tpl

Where does the code need to be placed if you want an extra field in one of the emails (skin1/mail/html/drop_shipper_email.tpl)?

I have the following code to put in the email template:
{if $products[product].extra_fields ne ''}
{foreach from=$products[product].extra_fields item=extra_field}
{if $extra_field.service_name eq "Kit Contents"}
{$extra_field.field}: {$extra_field.value}
{/if}
{/foreach}
{/if}

But I need to know where to place the code to assign the extra fields to the Smart template engine.
I hava already added an extra field to the cart by adding the code in "include/func/func.cart.php". What is the similar for email?

Thanks, Sam
__________________
spwestwood.
Version 4.1.9
Version 4.4
Reply With Quote
  #10  
Old 02-05-2008, 04:00 PM
 
7thdesire 7thdesire is offline
 

Senior Member
  
Join Date: Sep 2006
Posts: 115
 

Default Re: Extra Fields 4.1.x products_t.tpl

has anyone got this to work on

4.1.9 in products_t.tpl
__________________
X-cart - 4.3.2 loads of mods and custom code
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



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 03:27 AM.

   

 
X-Cart forums © 2001-2020