Guest Posted July 28, 2003 Share Posted July 28, 2003 I've just tried to install the main categories contrib, which shows all subcategories on the main page. It should be simple - I only have to do 3 things!!! :oops: But it tells me to find the following code: <tr> <td class="main"><br><?php include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_MAINPAGE); ?></td> </tr> in default.php, and it ain't there. I'm supposed to add some stuff after it. I've tried putting it in other places, and it works, but I get the following error message on the page: Warning: Invalid argument supplied for foreach() in /home/dan/public_html/lightoptions/includes/modules/main_categories.php on line 52 any ideas? Quote Link to comment Share on other sites More sharing options...
Guest Posted July 28, 2003 Share Posted July 28, 2003 What is the code it tells you to put after it? -Matt Quote Link to comment Share on other sites More sharing options...
Guest Posted July 28, 2003 Share Posted July 28, 2003 it tells me to put this in: <tr> <td><?php include(DIR_WS_MODULES . MAIN_CATEGORIES); ?></td> </tr> which calls a page I had to put into catalog/includes/modules I also had to put this into application_top anywhere: define('MAIN_CATEGORIES', 'main_categories.php'); dunno if it helps, but the contents of the main_categories.php file are: <?php /* $Id: main_categories.php,v 1.0a 2002/08/01 10:37:00 Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com/ Copyright (c) 2002 Barreto Gustavo Barreto <[email protected]> http://www.barreto.net/ Based on: all_categories.php Ver. 1.6 by Christian Lescuyer History: 1.0 Creation 1.0a Correction: Extra Carriage Returns Released under the GNU General Public License */ // Preorder tree traversal function preorder($cid, $level, $foo, $cpath) { global $categories_string, $HTTP_GET_VARS; // Display link if ($cid != 0) { for ($i=0; $i<$level; $i++) $categories_string .= ' '; $categories_string .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath =' . $cpath . $cid) . '">'; // 1.6 Are we on the "path" to selected category? $bold = strstr($HTTP_GET_VARS['cPath'], $cpath . $cid . '_') || $HTTP_GET_VARS['cPath'] == $cpath . $cid; // 1.6 If yes, use <b> if ($bold) $categories_string .= '<b>'; $categories_string .= $foo[$cid]['name']; if ($bold) $categories_string .= '</b>'; $categories_string .= '</a>'; // 1.4 SHOW_COUNTS is 'true' or 'false', not true or false if (SHOW_COUNTS == 'true') { $products_in_category = tep_count_products_in_category($cid); if ($products_in_category > 0) { $categories_string .= ' (' . $products_in_category . ')'; } } $categories_string .= '<br>'; } // Traverse category tree foreach ($foo as $key => $value) { if ($foo[$key]['parent'] == $cid) { // print "$key, $level, $cid, $cpath<br>"; preorder($key, $level+1, $foo, ($level != 0 ? $cpath . $cid . '_' : '')) ; } } } ?> <!-- main_categories //--> <tr> <td> <?php ////////// // Display box heading ////////// $info_box_contents = array(); $info_box_contents[] = array('align' => 'left', 'text' => BOX_HEADING_CATEGORIES); new infoBoxHeading($info_box_contents, true, false); ////////// // Get categories list ////////// // 1.2 Test for presence of status field for compatibility with older versions $status = tep_db_num_rows(tep_db_query('describe categories status')); $query = "select c.categories_id, cd.categories_name, c.parent_id, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id"; // 1.3 Can't have 'where' in an if statement! if ($status >0) $query.= " and c.status = '1'"; $query.= " and cd.language_id='" . $languages_id ."' order by sort_order, cd.categories_name"; $categories_query = tep_db_query($query); // Initiate tree traverse $categories_string = ''; preorder(0, 0, $foo, ''); ////////// // Display box contents ////////// $info_box_contents = array(); $row = 0; $col = 0; while ($categories = tep_db_fetch_array($categories_query)) { if ($categories['parent_id'] == 0) { $cPath_new = tep_get_path($categories['categories_id']); $text_subcategories = ''; $subcategories_query = tep_db_query($query); while ($subcategories = tep_db_fetch_array($subcategories_query)) { if ($subcategories['parent_id'] == $categories['categories_id']) { $cPath_new_sub = "cPath=" . $categories['categories_id'] . "_" . $subcategories['categories_id']; $text_subcategories .= '? <a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new_sub, 'NONSSL') . '">' . $subcategories['categories_name'] . '</ a>' . " "; } // if } // While Interno $info_box_contents[$row][$col] = array('align' => 'left', 'params' => 'class="smallText" width= "33%" valign="top"', 'text' => '<a href="' . tep_href_link (FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '</a><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '"><b>' . $categories['categories_name'] . '</b></a><br>' . $text_subcategories ); $col ++; if ($col > 1) { $col = 0; $row ++; } } } new contentBox($info_box_contents); ?> </td> </tr> <!-- main_categories_eof //--> Quote Link to comment Share on other sites More sharing options...
Guest Posted July 28, 2003 Share Posted July 28, 2003 I found the code on line 66 of default.php require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT); -Matt Quote Link to comment Share on other sites More sharing options...
Mooligan Posted July 28, 2003 Share Posted July 28, 2003 I had this same question awhile back, your answers are here: http://www.oscommerce.com/forums/viewtopic.php...8348&highlight= Both on where to put the code, and a link I provide towards the bottom will solve your foreach() problem. HTH Mooligan. Quote Link to comment Share on other sites More sharing options...
Guest Posted July 29, 2003 Share Posted July 29, 2003 thanks guys. will have a fiddle! 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.