aresman Posted April 8, 2005 Share Posted April 8, 2005 Okay, so this is the code from the Content Outside OSC Contrib. But, I'm having a pain in the butt time trying to get it to work entirely, and I'm not sure why. It works to display the photo of the item, and the link even works. BUT, the product name and price don't show up. (I placed the dddd, etc. in there to make sure it was displaying in general.) If you can help, I would REALLY REALLY appreciate it. Code: <?php /******************************************************** CONTENT OUTSIDE OF OSC V1.1 Author: David Vance == Adapted for MS2 by Anthony Date: 20. 11, 2004 OSC 2.2 MS2 PHP Version 4.3.2 This snippet is an example of placing osCommerce content on your site outside of the OSC directory structure. It allows you to display the products_new table. ********************************************************/ //saves current working directory for later return $cwd=getcwd(); //changes current working directory to osc root install directory; something like: /home/david/public_html/catalog/ but not DIR_FS_CATALOG chdir('/home/mysitename/public_html/'); //need all of application_top's configurations and includes; NO OUTPUT ABOVE THIS POINT! include('includes/application_top.php'); //need the language file require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCTS_NEW); //start buffering ob_start(); /* BEGIN: From the products_new.php page: */ if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status = '1' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) { ?> <?php $random_product['products_name'] = tep_get_products_name($random_product['products_id']); $random_product['specials_new_products_price'] = tep_get_products_special_price($random_product['products_id']); $info_box_contents = array(); $info_box_contents[] = array('text' => HEADING_TITLE); new infoBoxHeading($info_box_contents, false, false, tep_href_link(FILENAME_PRODUCTS_NEW)); if (tep_not_null($random_product['specials_new_products_price'])) { $whats_new_price = '<s>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</s><br>'; $whats_new_price .= '<span class="productSpecialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>'; } else { $whats_new_price = $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])); } $info_box_contents = array(); $info_box_contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'],SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br />dddd' . $random_product['products_name'] . '<br>asdf' . $whats_new_price); new infoBox($info_box_contents); } ?> <?php $newProductsTable = ob_get_contents(); //stop buffering ob_end_clean(); ?> <?php //start buffering ob_start(); if (isset($current_category_id) && ($current_category_id > 0)) { $best_sellers_query = tep_db_query("select distinct p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and '" . (int)$current_category_id . "' in (c.categories_id, c.parent_id) order by p.products_ordered desc, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS); } else { $best_sellers_query = tep_db_query("select distinct p.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_ordered desc, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS); } if (tep_db_num_rows($best_sellers_query) >= MIN_DISPLAY_BESTSELLERS) { ?> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => '<div class=left>Our Best Sellers</div>'); new infoBoxHeading($info_box_contents, false, false); $rows = 0; $bestsellers_list = '<table border="0" width="100%" cellspacing="0" cellpadding="1" align="center">'; while ($best_sellers = tep_db_fetch_array($best_sellers_query)) { $rows++; $bestsellers_list .= '<tr><td class="infoBoxContents" valign="top">' . tep_row_number_format($rows) . '.</td><td class="infoBoxContents"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $best_sellers['products_id']) . '">' . $best_sellers['products_name'] . '</a></td></tr>'; } $bestsellers_list .= '</table>'; $info_box_contents = array(); $info_box_contents[] = array('text' => $bestsellers_list); new infoBox($info_box_contents); } ?> <?php $bestsellersTable = ob_get_contents(); //stop buffering ob_end_clean(); ?> <?php /* END: From the products_new.php page */ //replace relative image paths with absolute urls (you may not need this. i did.) $newProductsTable=str_replace('src="', 'src="http://buy.mysite.com/',$newProductsTable); $bestsellersTable=str_replace('src="', 'src="http://buy.mysite.com/',$bestsellersTable); //change back to original working directory chdir($cwd); //********* COPY THE CODE ABOVE TO THE TOP OF THE FILE YOU WANT YOUR BOX IN *******\\ ?> <!-- ********* SAMPLE PAGE USAGE BELOW ********* --> <html><head> <!--make sure to include the stylesheet if you want the box to have same style as your shop--> <!--<link rel="stylesheet" type="text/css" href="http://buy.mysite.com/stylesheet.css" /> --> </head> <body> <center> <table> <tr><td width="150" align="center"> <?php echo $newProductsTable; //output your table here (or wherever) ?> <!--</td> --> <!--<td width=125> --> <!--<?php echo $bestsellersTable; //output your table here (or wherever) ?> --> </td> </tr> </table> </center> </body> </html> Quote Link to comment Share on other sites More sharing options...
aresman Posted April 8, 2005 Author Share Posted April 8, 2005 Thanks everyone - someone on CRELoaded.com helped me out with something that worked perfectly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.