![]() |
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)) { 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 |
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 :(
|
Re: Extra Fields 4.1.x products_t.tpl
nn... it doesnt work...why??
I'm now using 4.1.3 |
Re: Extra Fields 4.1.x products_t.tpl
I added the code
Code:
{foreach from=$products[product].extra_fields item="ef"} into '/skin1/customer/main/products.tpl' instead of products_t.tpl and it works. Thank you! |
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 |
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)) { 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 Trying everything, I gave Code:
{$extra_fields|@debug_print_var} 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. |
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. |
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 |
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 |
Re: Extra Fields 4.1.x products_t.tpl
has anyone got this to work on
4.1.9 in products_t.tpl |
Re: Extra Fields 4.1.x products_t.tpl
I got this to work in 4.1.9. The only problem is that you are not able to set the order. Its not using the service name nor the order by function. It must just be pulling the info straight from the database in the order it was added. Really need a way to fix this. Anyone have any ideas?
Also, need a way to not show some extra fields. Tried to hardcode, but couldnt get it to work. -DS |
Re: Extra Fields 4.1.x products_t.tpl
When you set up the extra fields, you can select the position of the extra field.
If you number them the way you want, they should show up in that order. |
Re: Extra Fields 4.1.x products_t.tpl
Quote:
This is true, for the product pages, but not for this mod. they are showing up in the order they were entered into the database. -ds |
Re: Extra Fields 4.1.x products_t.tpl
Just add "ORDER BY $sql_tbl[extra_fields].orderby")" to the end of the SQL query in products.php to use the sort order -
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, $sql_tbl[extra_fields].active as active 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]' ORDER BY $sql_tbl[extra_fields].orderby"); } } I also added "$sql_tbl[extra_fields].active as active FROM $sql_tbl[extra_fields]," so I can still specify to show the field value if it's active right on the .tpl. |
Re: Extra Fields 4.1.x products_t.tpl
Can I use this code for product.tpl (4.1.9)?
Many thanks, |
Re: Extra Fields 4.1.x products_t.tpl
Product.tpl is already set up to show extra fields, the code is meant for other templates that show products but don't show extra fields (by default).
And the code does work for 4.1.9. Tony |
Re: Extra Fields 4.1.x products_t.tpl
Thank you very much Tony. I▓ve placed the code to product.php and product.tpl and all I▓ve got is:
1 : 1 Any ideas what I▓ve done wrong? Many thanks, |
Re: Extra Fields 4.1.x products_t.tpl
Hi,
I need to get this working in the cart i have added : # # Get products Extra field data # 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]'"); } } $smarty->assign("products",$products); to the cart.php and tried it in the include/cart_procsess.php but it does not show up in the view cart, anyone have any ideas? Also added {$products[product].extra_fields[1].field}{$products[product].extra_fields[1].value} to the cart.tpl Many Thanks |
Re: Extra Fields 4.1.x products_t.tpl
Am I understanding that X-Cart included the above code to product.tpl for extra fields? Without adding the above mod, I've tried calling out an extra field in my product.tpl as {$product.extra_fields.6.value}, but it doesn't work. Do you have a suggestion?
Quote:
|
Re: Extra Fields 4.1.x products_t.tpl
Hi Christine,
You need to LOOP through the Extra fields and display the one using an {if} statement - Code:
{section name=field loop=$extra_fields} |
Re: Extra Fields 4.1.x products_t.tpl
Hi toltion,
How does this work for multiple extra fields on the product.tpl page? Quote:
|
Re: Extra Fields 4.1.x products_t.tpl
The code allows you to selectively display any extra field. I sometimes like to display the extra fields in different locations on the template, so I run the code at the top of the page and assign variables to the values. In this code I chose to identify the extra_fields by their Service Name instead of index position in the loop -
Code:
{section name=field loop=$extra_fields} Then I can display the variables "no_ship_air" & "clearance_price" anywhere on the page using {if $no_ship_air ne ""}{$no_ship_air}{/if}. |
Re: Extra Fields 4.1.x products_t.tpl
With your suggested code, I believe I have the "loop through" working in /modules/Extra_Fields/product.tpl, though I haven't been able to place each of my extra fields separately in customer/main/product.tpl.
This is what I have for my product.tpl {if $active_modules.Extra_Fields ne ""} {include file="modules/Extra_Fields/product.tpl"} When I tried adding just one field name, there was no change {if $active_modules.Extra_Fields ne ""}{$product.extra_fields.11.value} {include file="modules/Extra_Fields/product.tpl"} Can you see what I'm missing to call out individual extra fields where I need in my customer/main/product.tpl? Christine Quote:
|
Re: Extra Fields 4.1.x products_t.tpl
In customer/main/product.tpl, you have to replace -
{include file="modules/Extra_Fields/product.tpl"} With the code I suggested. You are basically looping through the extra fields directly on product.tpl instead of including "modules/Extra_Fields/product.tpl". |
Re: Extra Fields 4.1.x products_t.tpl
Awesome! I have one more piece to this that I need working. I have a custom button that I'm trying to get working for 3 of my extra fields. Here's what I've done with trying to add my custom button .tpl:
In customer/main/product.tpl I commented out <!--{if $active_modules.Extra_Fields ne ""} {include file="modules/Extra_Fields/product.tpl"} {/if}--> and added from your code suggestion <table align="left" cellspacing="0" cellpadding="0"> {section name=field loop=$extra_fields} <td>{if $extra_fields[field].service_name eq "products_PDF"} {include file="buttons/pdf_button.tpl" href="javascript:window.open $extra_fields[field].field_value=products_PDF" style="button"} {/if}</td> <td> </td> <td>{if $extra_fields[field].service_name eq "products_manual"} {$extra_fields[field].field_value eq "products_manual"} {/if}</td> <td> </td> <td>{if $extra_fields[field].service_name eq "product_image"} {$extra_fields[field].field_value eq "product_image"} {/if}</td> {/section} </table> The bold is my attempt for my custom button. The image of my custom button is now showing, though it's not clickable to my product. Do you have any suggestions? Christine Quote:
|
Re: Extra Fields 4.1.x products_t.tpl
Try this...
<table align="left" cellspacing="0" cellpadding="0"> {section name=field loop=$extra_fields} <td>{if $extra_fields[field].service_name eq "products_PDF"} {include file="buttons/pdf_button.tpl" href="javascript:window.open $extra_fields[field].field_value" style="button"} {/if}</td> <td> </td> <td>{if $extra_fields[field].service_name eq "products_manual"} {$extra_fields[field].field_value} {/if}</td> <td> </td> <td>{if $extra_fields[field].service_name eq "product_image"} {$extra_fields[field].field_value} {/if}</td> {/section} </table> Not too sure about your javascript window.open code. Doesn't look like that will work... |
Re: Extra Fields 4.1.x products_t.tpl
Great job. Thanks for your help! I have the loop through working.
For my custom button, I will need to get mod work done. Christine |
Re: Extra Fields 4.1.x products_t.tpl
Thank you thank you!
|
Re: Extra Fields 4.1.x products_t.tpl
Hi,
I can't find where to insert the code in 4.1.11 as I can't find the $smarty->assign line mentioned. Where should I insert this to call up the extra fields? Thanks, Chris |
Re: Extra Fields 4.1.x products_t.tpl
Are you modifying products.php? It should be near the last lines of the file. The php code goes in the products.php file, the smarty and html changes go in the template files.
|
Re: Extra Fields 4.1.x products_t.tpl
Thanks, I didn't read that first post correctly. I've edited products.php but still don't quite understand what and where to put the rest of the code for this mod for the extra fields to show up in in the products template. I've tried and still, nothing is showing up.
Time to just quit, but thanks for your help. |
Re: Extra Fields 4.1.x products_t.tpl
I'm looking at displaying some extra fields on the search display page.
Will this mod work on 4.1.12? |
Re: Extra Fields 4.1.x products_t.tpl
Unless I'm missing something I'm pretty sure this mod is not necessary with 4.1:
http://forum.x-cart.com/showthread.php?p=118321#post118321 (there are some typos in the example) |
Re: Extra Fields 4.1.x products_t.tpl
Is it possible to import from 3x-4x import?what are the fields?
|
Re: Extra Fields 4.1.x products_t.tpl
Can anyone tell me if there is a patch after 4.1.8 that makes adding a field to the products_t.tpl easier, or do i still need to follow the instructions for a change from this thread?
Thanks!!!!! in advance |
Re: Extra Fields 4.1.x products_t.tpl
Quote:
|
Re: Extra Fields 4.1.x products_t.tpl
This isnt working on 4.2.1 any ideas how to make this work?
|
Re: Extra Fields 4.1.x products_t.tpl
Cherry Is it possible to import from 3x-4x import?what are the fields?
|
Re: Extra Fields 4.1.x products_t.tpl
Quote:
Yep! It's called "Extra Fields." You should see the fields when you create the export. In 4.1 you can enable the module called "Import 3x-4x". You can then see that at the top when you go to Import/Export. |
Re: Extra Fields 4.1.x products_t.tpl
Cherry I have made two extra fields 1)Pack Size 2)Attribute .How Can I import these from 3x-4x import? What are the field value name?
Can you help me? |
All times are GMT -8. The time now is 08:18 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.