X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Extra Fields 4.1.x products_t.tpl (https://forum.x-cart.com/showthread.php?t=25143)

Cpt.Crashtastic 09-21-2006 12:47 PM

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

balinor 09-21-2006 12:58 PM

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 :(

HEK 10-30-2006 03:04 PM

Re: Extra Fields 4.1.x products_t.tpl
 
nn... it doesnt work...why??
I'm now using 4.1.3

KeeYoung Hartley 01-11-2007 11:49 AM

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!

bradjd 01-26-2007 11:24 AM

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

jhoyssa 01-29-2007 04:43 AM

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.

carlisleglass 06-12-2007 01:41 AM

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.

vtonya 06-12-2007 10:57 AM

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

spwestwood 09-21-2007 07:21 AM

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

7thdesire 02-05-2008 04:00 PM

Re: Extra Fields 4.1.x products_t.tpl
 
has anyone got this to work on

4.1.9 in products_t.tpl


All times are GMT -8. The time now is 03:50 AM.

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