![]() |
|
|||||||
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
#1
IP: 117.95.1.180
|
|||
|
|||
|
Thought I would share this since the older answers do not really work...in XCart 4.7, if you want to have extra fields on the product listing page, you must add the fields to the product loop in products.php...i struggled with this for a few days, but with xcart support's help, i was able to craft this very simple code for my extra fields to show on the product listing page...
In products.php just before the line $smarty->assign('cat_products', isset($products) ? $products : array()); add this code and be sure to change the values to match your extra fields... foreach($products as $c => $v) { $products[$c]['calories'] = func_query_first_cell("SELECT value FROM $sql_tbl[extra_field_values] WHERE productid='$v[productid]' AND fieldid = '2'"); $products[$c]['protein'] = func_query_first_cell("SELECT value FROM $sql_tbl[extra_field_values] WHERE productid='$v[productid]' AND fieldid = '3'"); $products[$c]['fat'] = func_query_first_cell("SELECT value FROM $sql_tbl[extra_field_values] WHERE productid='$v[productid]' AND fieldid = '5'"); $products[$c]['carbs'] = func_query_first_cell("SELECT value FROM $sql_tbl[extra_field_values] WHERE productid='$v[productid]' AND fieldid = '4'"); } $smarty->assign('calories', $calories); $smarty->assign('protein', $protein); $smarty->assign('fat', $fat); $smarty->assign('carbs', $carbs); pay attention to the 'fieldid' in the script...it is at the end of each line and you must figure out which fieldid in the database you want to have the value from...look in the table 'xcart_extra_field_values' and look at the 'fieldid' column and match that to the extra field you are trying to show[/b] in my example, i have some food stuff... Calories, Fat, Protein, Carbs...they are all extra fields and i went into the aforementioned tabled and got their 'fieldid's and then i put them into this script... THEN in products_t.tpl add these smarty tags wherever you want to show the extra field values...be sure to add these tags inside the {foreach}{/foreach} loop {$product.calories} {$product.protein} {$product.fat} {$product.carbs} |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Redirect to Product Page when only One product in category | Pace | X-Cart | 2 | 2016-02-14 07:44 PM |
| Display product extra field data on Invoice | Hahira | X-Cart | 0 | 2015-12-02 06:47 PM |
| htaccess 301 redirect tutorial | yahoo | 服务器环境搭建 | 0 | 2009-09-06 12:45 AM |
| What are the Strongest Directories? | smiling | 网站链接开发 | 1 | 2007-07-28 09:26 PM |
| Building for the user and the bot. | admin | 建站交流 | 0 | 2006-01-17 03:54 PM |