radhavallabh Posted October 23, 2015 Posted October 23, 2015 Hi, I would like to display the content of a box module in a div on the index.php (To be displayed when products under a category are displayed)...Can someone please help me that which snippet/part of the box modules should be used to display them in Divs as well. For example how to display the output of below box module in a div on index.php also- <?php /* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2010 osCommerce Released under the GNU General Public License */ class bm_reviews { var $code = 'bm_reviews'; var $group = 'boxes'; var $title; var $description; var $sort_order; var $enabled = false; function bm_reviews() { $this->title = MODULE_BOXES_REVIEWS_TITLE; $this->description = MODULE_BOXES_REVIEWS_DESCRIPTION; if ( defined('MODULE_BOXES_REVIEWS_STATUS') ) { $this->sort_order = MODULE_BOXES_REVIEWS_SORT_ORDER; $this->enabled = (MODULE_BOXES_REVIEWS_STATUS == 'True'); $this->group = ((MODULE_BOXES_REVIEWS_CONTENT_PLACEMENT == 'Left Column') ? 'boxes_column_left' : 'boxes_column_right'); } } function execute() { global $languages_id, $HTTP_GET_VARS, $currencies, $oscTemplate; // $random_select = "select r.reviews_id, r.reviews_rating, p.products_id, p.products_image, pd.products_name from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd, " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = r.products_id and r.reviews_id = rd.reviews_id and rd.languages_id = '" . (int)$languages_id . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and r.reviews_status = 1"; // if (isset($HTTP_GET_VARS['products_id'])) { // $random_select .= " and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'"; // } // $random_select .= " order by r.reviews_id desc limit " . MAX_RANDOM_SELECT_REVIEWS; //on/off global $languages_id, $HTTP_GET_VARS, $currencies, $oscTemplate, $hiddencats; if (!empty($hiddencats)) { $random_select = "select r.reviews_id, r.reviews_rating, p.products_id, p.products_image, pd.products_name from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd, " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.products_id = r.products_id and r.reviews_id = rd.reviews_id and rd.languages_id = '" . (int)$languages_id . "' and p.products_id = pd.products_id and p.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and (not (p2c.categories_id in (" . implode(',', $hiddencats) . ")))"; } else { $random_select = "select r.reviews_id, r.reviews_rating, p.products_id, p.products_image, pd.products_name from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd, " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = r.products_id and r.reviews_id = rd.reviews_id and rd.languages_id = '" . (int)$languages_id . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and r.reviews_status = 1"; } if (isset($HTTP_GET_VARS['products_id'])) { $random_select .= " and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'"; } $random_select .= " group by p.products_id order by r.reviews_id desc limit " . MAX_RANDOM_SELECT_REVIEWS; $random_product = tep_random_select($random_select); $reviews_box_contents = ''; if ($random_product) { // display random review box $rand_review_query = tep_db_query("select substring(reviews_text, 1, 60) as reviews_text from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . (int)$random_product['reviews_id'] . "' and languages_id = '" . (int)$languages_id . "'"); $rand_review = tep_db_fetch_array($rand_review_query); $rand_review_text = tep_break_string(tep_output_string_protected($rand_review['reviews_text']), 15, '-<br />'); $reviews_box_contents .= '<div class="infoBoxContents"><div align="center"><a class="img_conteiner" href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_INFO, 'products_id=' . $random_product['products_id'] . '&reviews_id=' . $random_product['reviews_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, '') . '</a></div><a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_INFO, 'products_id=' . $random_product['products_id'] . '&reviews_id=' . $random_product['reviews_id']) . '">' . $rand_review_text . ' ..</a><br /> <div align="center">' .rating_output($random_product['products_id']) . '</div> </div>'; } elseif (isset($HTTP_GET_VARS['products_id'])) { // display 'write a review' box $reviews_box_contents .= '<table border="0" cellspacing="0" cellpadding="2" class="infoBoxContents NoReview"><tr><td><a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, 'products_id=' . $HTTP_GET_VARS['products_id']) . '">' . MODULE_BOXES_REVIEWS_BOX_WRITE_REVIEW .'</a></td></tr></table>'; } else { // display 'no reviews' box $reviews_box_contents .= '<div class="infoBoxContents">' . MODULE_BOXES_REVIEWS_BOX_NO_REVIEWS . '</div>'; } $data = '<div class="infoBox infoBoxReviews">' . ' <div class="infoBoxHeading"><a href="' . tep_href_link(FILENAME_REVIEWS) . '">' . MODULE_BOXES_REVIEWS_BOX_TITLE . '</a></div>' . $reviews_box_contents . '</div>'; $oscTemplate->addBlock($data, $this->group); } function isEnabled() { return $this->enabled; } function check() { return defined('MODULE_BOXES_REVIEWS_STATUS'); } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Reviews Module', 'MODULE_BOXES_REVIEWS_STATUS', 'True', 'Do you want to add the module to your shop?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Placement', 'MODULE_BOXES_REVIEWS_CONTENT_PLACEMENT', 'Right Column', 'Should the module be loaded in the left or right column?', '6', '1', 'tep_cfg_select_option(array(\'Left Column\', \'Right Column\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_BOXES_REVIEWS_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { return array('MODULE_BOXES_REVIEWS_STATUS', 'MODULE_BOXES_REVIEWS_CONTENT_PLACEMENT', 'MODULE_BOXES_REVIEWS_SORT_ORDER'); } } ?> Help would be deeply appreciated; Thanks in advance....Regards/ radhavallabh
radhavallabh Posted October 23, 2015 Author Posted October 23, 2015 Sorry I forgot to mention using oscommerce 2.3.4 and php 5.3
♥Tsimi Posted October 23, 2015 Posted October 23, 2015 Multimixer wrote an excellent article about it here.
radhavallabh Posted October 23, 2015 Author Posted October 23, 2015 @@Tsimi Thank you so very much for helping me......You and Multimixer rock..... It works like a charm....... :)
multimixer Posted October 23, 2015 Posted October 23, 2015 @@radhavallabh Greeks always rock, didn't you know? My community profile | Template system for osCommerce - New: Responsive | Feedback channel
radhavallabh Posted October 24, 2015 Author Posted October 24, 2015 @@multimixer Surely Do!!!! :thumbsup: Thanks again.......
Recommended Posts
Archived
This topic is now archived and is closed to further replies.