johnduo0007 Posted April 15, 2008 Posted April 15, 2008 Im trying to add the "short description" contribution to catalog/includes/modules/featured/php but im no expert. Can't get it to work. I added the following code, but it gives me an error message when I upload and load the index.php The code I modified is in bold and I enlarge the font size so it's easy to see. CODE: <?php /* osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2002 osCommerce Released under the GNU General Public License Featured Products V1.1 Displays a list of featured products, selected from admin For use as an Infobox instead of the "New Products" Infobox */ ?> <!-- featured_products //--> <?php if(FEATURED_PRODUCTS_DISPLAY == 'true') { $featured_products_category_id = $new_products_category_id; $cat_name_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . $featured_products_category_id . "' limit 1"); $cat_name_fetch = tep_db_fetch_array($cat_name_query); $cat_name = $cat_name_fetch['categories_name']; $info_box_contents = array(); if ( (!isset($featured_products_category_id)) || ($featured_products_category_id == '0') ) { $info_box_contents[] = array('align' => 'left', 'text' => TABLE_HEADING_FEATURED_PRODUCTS); list($usec, $sec) = explode(' ', microtime()); srand( (float) $sec + ((float) $usec * 100000) ); $mtm= rand(); $featured_products_query = tep_db_query("select p.products_id, p.products_image, pd.short_desc, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' order by rand($mtm) DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS); } else { $info_box_contents[] = array('align' => 'left', 'text' => sprintf(TABLE_HEADING_FEATURED_PRODUCTS_CATEGORY, $cat_name)); $subcategories_array = array(); tep_get_subcategories($subcategories_array, $featured_products_category_id); $featured_products_category_id_list = tep_array_values_to_string($subcategories_array); if ($featured_products_category_id_list == '') { $featured_products_category_id_list .= $featured_products_category_id; } else { $featured_products_category_id_list .= ',' . $featured_products_category_id; } $featured_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c using(products_id) left join " . TABLE_CATEGORIES . " c using(categories_id) left join " . TABLE_FEATURED . " f on p.products_id = f.products_id left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where c.parent_id = '" . $featured_products_category_id . "' and p.products_status = '1' and f.status = '1' order by rand() DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS); } $row = 0; $col = 0; $num = 0; while ($featured_products = tep_db_fetch_array($featured_products_query)) { $num ++; if ($num == 1) { new contentBoxHeading($info_box_contents); } $featured_products['products_name'] = tep_get_products_name($featured_products['products_id']); if($featured_products['specstat']) { $info_box_contents[$row][$col] = array('align' => 'center', 'params' => ' style="width:50%;"', 'text' => ''.tep_draw_prod_top().' <table cellpadding="0" cellspacing="0" border="0" style="background:#ebebeb;height:39px"> <tr><td>'.tep_draw_separator('spacer.gif', '14', '1').'</td> <td style="width:100%; vertical-align:middle;"><span><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] . '</a></span></td> <td>'.tep_draw_separator('spacer.gif', '10', '1').'</td> </tr> </table> <table cellpadding="0" cellspacing="0" border="0" style="height:173px"> <tr> <td style="width:126px" align="center" class="vam"><span><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br></td> <td style="width:132px"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td style="height:91px " class="vam">' . $featured_products['short_desc'] . '</td></tr> </table> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td style="height:51px "> <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">'.tep_image_button("button_details.gif").'</a><br> <br> </td> </tr> </table> </td> </tr> </table> '.tep_draw_prod_bottom().'');} else { $info_box_contents[$row][$col] = array('align' => 'center', 'params' => ' style="width:50%;"', 'text' => ''.tep_draw_prod_top().' <table cellpadding="0" cellspacing="0" border="0" style="background:#ebebeb;height:39px"> <tr><td>'.tep_draw_separator('spacer.gif', '14', '1').'</td> <td style="width:100%; vertical-align:middle;"><span><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] . '</a></span></td> <td>'.tep_draw_separator('spacer.gif', '10', '1').'</td> </tr> </table> <table cellpadding="0" cellspacing="0" border="0" style="height:173px"> <tr> <td style="width:126px" align="center" class="vam"><span><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br></td> <td style="width:132px"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td style="height:91px " class="vam">' . $featured_products['short_desc'] . '</td></tr> </table> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td style="height:51px "> <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">'.tep_image_button("button_details.gif").'</a><br> <br> </td> </tr> </table> </td> </tr> </table> '.tep_draw_prod_bottom().''); } $col ++; if ($col > 1) { $col = 0; $row ++; } } if($num) { new contentBox($info_box_contents); } } else // If it's disabled, then include the original New Products box { // include (DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); // disable for dont show if desactive the feature module } ?> <!-- featured_products_eof //-->
photofxplus Posted April 15, 2008 Posted April 15, 2008 <td style="height:91px " class="vam">' . $featured_products['short_desc'] . '</td></tr> needs to be: <td style="height:91px " class="vam"><?php echo $featured_products['short_desc']; ?></td></tr> Lloyd
♥FWR Media Posted April 15, 2008 Posted April 15, 2008 <td style="height:91px " class="vam">' . $featured_products['short_desc'] . '</td></tr>needs to be: <td style="height:91px " class="vam"><?php echo $featured_products['short_desc']; ?></td></tr> No it is correct, the html is being parsed by PHP. The problem is the query I think. You are querying for pd.short_desc yet you havent added the table products_description to query from. You should recheck the install notes. Also in future instead of just throwing a complete file at us please at least give us the error message to go on. Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls KissMT Dynamic SEO Meta & Canonical Header Tags KissER Error Handling and Debugging KissIT Image Thumbnailer Security Pro - Querystring protection against hackers ( a KISS contribution ) If you found my post useful please click the "Like This" button to the right. Please only PM me for paid work.
photofxplus Posted April 15, 2008 Posted April 15, 2008 Yes you are right Robert - the text is being parsed.. What a string huh??! Lloyd
johnduo0007 Posted April 15, 2008 Author Posted April 15, 2008 <td style="height:91px " class="vam">' . $featured_products['short_desc'] . '</td></tr>needs to be: <td style="height:91px " class="vam"><?php echo $featured_products['short_desc']; ?></td></tr> Thank Photofxplus, that didn't work either, I thought it would when you posted it. It's giving me this error: 1054 - Unknown column 'short_desc' in 'field list' select p.products_id, short_desc, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from products p left join specials s on p.products_id = s.products_id left join featured f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' order by rand(1112885209) DESC limit 6 I've tried so many things, but still I can figure this out :'(
photofxplus Posted April 15, 2008 Posted April 15, 2008 1054 - Unknown column 'short_desc' in 'field list' select p.products_id, short_desc, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from products p left join specials s on p.products_id = s.products_id left join featured f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' order by rand(1112885209) DESC limit 6 I've tried so many things, but still I can figure this out :'( Just noticed somthing in the query: change short_desc to p.short_desc.. Lloyd
johnduo0007 Posted April 15, 2008 Author Posted April 15, 2008 No it is correct, the html is being parsed by PHP. The problem is the query I think. You are querying for pd.short_desc yet you havent added the table products_description to query from. You should recheck the install notes. Also in future instead of just throwing a complete file at us please at least give us the error message to go on. Thanks FWR Media, Sorry about throwing the complete file :blush: Anyway, the problem is that I think there are no notes for this as I am trying to do this by my own. I downloaded two contributions and just wanted featured.php to show the short description. Im not very familiar the a "table_products_description". Anyway, thanks for the help.
johnduo0007 Posted April 15, 2008 Author Posted April 15, 2008 Just noticed somthing in the query:change short_desc to p.short_desc.. I did that already, I tried p.short_desc and pd.short_desc It gave me the same error
photofxplus Posted April 15, 2008 Posted April 15, 2008 1054 - Unknown column 'short_desc' in 'field list' select p.products_id, short_desc, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from products p left join specials s on p.products_id = s.products_id left join featured f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' order by rand(1112885209) DESC limit 6 If this is the error than the column short_desc does does not have a p. in front -- plus if the column is in the table 'products_description' then Robert is right.. That table is not even in the query. Lloyd
Recommended Posts
Archived
This topic is now archived and is closed to further replies.