| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Extra Fields on Products.tpl | |||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
![]() I have seen a lot of posts about adding extra fields to various things, but I haven't been able to get what I found to work like I want it to.
I need to show on products.tpl, in a table, the extra fields that have a value. This is the code I added to products.php: 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]'"); } } And this is my products.tpl {if $products} <TABLE border=0 width=100% cellspacing="0"> <TR> <TD align=center class="top_products">Product</TD> {section name=field loop=$products[prod_num].extra_fields} {if $products[prod_num].extra_fields[field].field_value} <TD class="top_products"> {$products[prod_num].extra_fields[field].field} </TD> {/if} {/section} <TD align=center class="top_products">{$lng.lbl_price}</TD> </TR> {section name=product loop=$products} <TR {cycle values="class='tr_products1', class='tr_products2'"}> <TD align=left><A href="product.php?productid={$products[product].productid}">{$products[product].product}</A></TD> {section name=field loop=$products[prod_num].extra_fields} {if $products[prod_num].extra_fields[field].field_value} <TD> {$products[prod_num].extra_fields[field].field_value} </TD> {/if} {/section} <TD align=center><b><A href="product.php?productid={$products[product].productid}">{include file="currency.tpl" value=$products[product].taxed_price}</A></b></TD> </TR> {/section} </TABLE> {else} {$lng.txt_no_products_found} {/if} Can anyone point me to the right topic, or help me to get this working? I get the extra fields to show when I call them individually but that won't work because the table will be to big, I just need to show the ones that have a value. Thanks |
|||||||||
#2
|
|||||||||
|
|||||||||
![]() no help here? someone, anyone?
|
|||||||||
#3
|
|||||||||
|
|||||||||
![]() Nobody wants to help me with this? at least to tell me where I can find the answer? Pretty please with sugar on top?
|
|||||||||
#4
|
|||||||
|
|||||||
![]()
__________________
Padraic Ryan Ryan Design Studio Professional E-Commerce Development |
|||||||
#5
|
|||||||||
|
|||||||||
![]() Yes I went through that post. The extra fields are showing up fine when I call them individually, but there is something wrong with my loop or my if the extra field has a value then show it statement (don't know how to explain that better sorry). I can go through the whole process of calling individual extra fields for the certain types of products in each category, but this seems like a horrible waste of time. I just want to call the extra fields that have a value and show those, so the table is changing by itself for every category. The code as it is, does not show any extra fields. Is there something wrong with it that you can see? Like changing the {section name=field loop=$products[prod_num].extra_fields} to a foreach or something?
|
|||||||||
#6
|
|||||||||
|
|||||||||
![]() Six months later...I had another site to make, this one I could not get away with hard coding the extra fields and I found the solution.
In products.tpl I finally made a table that outputs a <th> with the extra field names, and <td> with the extra field values, and excludes the extra fields without a value. This only works if all the products in the current category have the same extra fields, which was the case with this project. Combined with the bcse buy now mod, this makes for a fast and easy way for customers to order a bunch of products. Code:
|
|||||||||
|
|||
X-Cart forums © 2001-2020
|