devosc Posted May 11, 2004 Share Posted May 11, 2004 catalog/includes/classes/category_tree.php /* $Id: category_tree.php,v MS2-2.2 2004/05/10 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2004 osCommerce Released under the GNU General Public License */ class osC_CategoryTree { var $root_category_id = 0, $max_level = 0, $data = array(), $root_start_string = '', $root_end_string = '', $parent_start_string = '', $parent_end_string = '', $parent_group_start_string = '<ul>', $parent_group_end_string = '</ul>', $child_start_string = '<li>', $child_end_string = '</li>', $spacer_string = '', $spacer_multiplier = 1; function osC_CategoryTree($load_from_database = true) { global $languages_id; $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by c.parent_id, c.sort_order, cd.categories_name"); $this->data = array(); while ($categories = tep_db_fetch_array($categories_query)) { $this->data[$categories['parent_id']][$categories['categories_id']] = array('name' => $categories['categories_name'], 'count' => 0); } } function buildBranch($parent_id, $level = 0) { $result = $this->parent_group_start_string; if (isset($this->data[$parent_id])) { foreach ($this->data[$parent_id] as $category_id => $category) { $category_link = $category_id; $result .= $this->child_start_string; if (isset($this->data[$category_id])) { $result .= $this->parent_start_string; } if ($level == 0) { $result .= $this->root_start_string; } $result .= str_repeat($this->spacer_string, $this->spacer_multiplier * $level) . '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '">'; $result .= $category['name']; $result .= '</a>'; if ($level == 0) { $result .= $this->root_end_string; } if (isset($this->data[$category_id])) { $result .= $this->parent_end_string; } $result .= $this->child_end_string; if (isset($this->data[$category_id]) && (($this->max_level == '0') || ($this->max_level > $level+1))) { $result .= $this->buildBranch($category_id, $level+1); } } } $result .= $this->parent_group_end_string; return $result; } function buildTree() { return $this->buildBranch($this->root_category_id); } } suggested contents for sitemap.php <table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td width="50%" class="main" valign="top"><?php require DIR_WS_CLASSES . 'category_tree.php'; $osC_CategoryTree = new osC_CategoryTree; echo $osC_CategoryTree->buildTree(); ?></td> <td width="50%" class="main" valign="top"> <ul> <li><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . PAGE_ACCOUNT . '</a>'; ?></li> <ul> <li><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_EDIT, '', 'SSL') . '">' . PAGE_ACCOUNT_EDIT . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL') . '">' . PAGE_ADDRESS_BOOK . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL') . '">' . PAGE_ACCOUNT_HISTORY . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_NEWSLETTERS, '', 'SSL') . '">' . PAGE_ACCOUNT_NOTIFICATIONS . '</a>'; ?></li> </ul> <li><?php echo '<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . PAGE_SHOPPING_CART . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . PAGE_CHECKOUT_SHIPPING . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '">' . PAGE_ADVANCED_SEARCH . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW) . '">' . PAGE_PRODUCTS_NEW . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_SPECIALS) . '">' . PAGE_SPECIALS . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_REVIEWS) . '">' . PAGE_REVIEWS . '</a>'; ?></li> <li><?php echo BOX_HEADING_INFORMATION; ?></li> <ul> <li><?php echo '<a href="' . tep_href_link(FILENAME_SHIPPING) . '">' . BOX_INFORMATION_SHIPPING . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_PRIVACY) . '">' . BOX_INFORMATION_PRIVACY . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_CONDITIONS) . '">' . BOX_INFORMATION_CONDITIONS . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_CONTACT_US) . '">' . BOX_INFORMATION_CONTACT . '</a>'; ?></li> </ul> </ul> </td> </tr> </table> pertaining catalog/includes/languages/english/sitemap.php define('NAVBAR_TITLE', 'Site Map'); define('HEADING_TITLE', 'Site Map'); define('PAGE_ACCOUNT', 'My Account'); define('PAGE_ACCOUNT_EDIT', 'Account Information'); define('PAGE_ADDRESS_BOOK', 'Address Book'); define('PAGE_ACCOUNT_HISTORY', 'Order History'); define('PAGE_ACCOUNT_NOTIFICATIONS', 'Newsletter Subscriptions'); define('PAGE_SHOPPING_CART', 'Shopping Cart'); define('PAGE_CHECKOUT_SHIPPING', 'Checkout'); define('PAGE_ADVANCED_SEARCH', 'Advanced Search'); define('PAGE_PRODUCTS_NEW', 'New Products'); define('PAGE_SPECIALS', 'Specials'); define('PAGE_REVIEWS', 'Reviews'); "Any fool can know. The point is to understand." -- Albert Einstein Link to comment Share on other sites More sharing options...
Guest Posted May 11, 2004 Share Posted May 11, 2004 Any body know what this does Is it like the seo sitemap Link to comment Share on other sites More sharing options...
savassahin Posted May 11, 2004 Share Posted May 11, 2004 I don't understand. Please explain how it is install.. Thanks.. :blink: Link to comment Share on other sites More sharing options...
molafish Posted May 12, 2004 Share Posted May 12, 2004 gregbaboolal is a minimalist. The expanded version of his post is: To display a site map, install three files: copy and paste the quotes into three files named and placed into their respective headers. The sitemap.php goes into the catalog (osC root) dir. But take care to add a few things: for catalog/includes/languages/english/sitemap.php : place this before what greg quoted: <?php/* $Id: sitemap.php,v 2.2 2004/05/11 23:26:23 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2004 osCommerce Released under the GNU General Public License */ place this after what greg quoted: ?> this is the one that takes some effort: catalog/sitemap.php You need to surround what greg quoted with *your* osC installation's default page content. So the best thing to do is open a simple file like catalog/shipping.php, save as -> catalog/sitemap.php Then make these changes: on line 14 and 16, where it says FILENAME_SHIPPING change it to say FILENAME_SITEMAP Then find in the middle of the file somewhere where between these two quotes: <!-- body_text //--> *delete all the stuff that's right here! <!-- body_text_eof //--> Insert this between them (a slight modification of greg's quoted code): <td width="50%" class="main" valign="top"><?php require DIR_WS_CLASSES . 'category_tree.php'; $osC_CategoryTree = new osC_CategoryTree; echo $osC_CategoryTree->buildTree(); ?></td> <td width="50%" class="main" valign="top"> <ul> <li><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . PAGE_ACCOUNT . '</a>'; ?></li> <ul> <li><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_EDIT, '', 'SSL') . '">' . PAGE_ACCOUNT_EDIT . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL') . '">' . PAGE_ADDRESS_BOOK . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL') . '">' . PAGE_ACCOUNT_HISTORY . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_NEWSLETTERS, '', 'SSL') . '">' . PAGE_ACCOUNT_NOTIFICATIONS . '</a>'; ?></li> </ul> <li><?php echo '<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . PAGE_SHOPPING_CART . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . PAGE_CHECKOUT_SHIPPING . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '">' . PAGE_ADVANCED_SEARCH . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW) . '">' . PAGE_PRODUCTS_NEW . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_SPECIALS) . '">' . PAGE_SPECIALS . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_REVIEWS) . '">' . PAGE_REVIEWS . '</a>'; ?></li> <li><?php echo BOX_HEADING_INFORMATION; ?></li> <ul> <li><?php echo '<a href="' . tep_href_link(FILENAME_SHIPPING) . '">' . BOX_INFORMATION_SHIPPING . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_PRIVACY) . '">' . BOX_INFORMATION_PRIVACY . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_CONDITIONS) . '">' . BOX_INFORMATION_CONDITIONS . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_CONTACT_US) . '">' . BOX_INFORMATION_CONTACT . '</a>'; ?></li> </ul> </ul> </td> </table></td> </tr> </table> we have another line to add to a file that greg did not specify, but before that, look to the following quote to see my entire file contents for sitemap.php (BEWARE: my setup is most likely different than yours, for instance, I have installed the header_tags contribution, and have removed the following lines from my page): <!-- right_navigation //--><?php require(DIR_WS_INCLUDES . 'column_right.php'); ?> <!-- right_navigation_eof //--> content's of molafish's sitemap.php (use the preceding method instead of copying this) <?php/* $Id: sitemap.php,v 2.2 2004/05/11 20:17:50 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2004 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_SITEMAP); $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_SITEMAP)); ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <?php // BOF: WebMakers.com Changed: Header Tag Controller v1.0 // Replaced by header_tags.php if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) { require(DIR_WS_INCLUDES . 'header_tags.php'); } else { ?> <title><?php echo TITLE; ?></title> <?php } // EOF: WebMakers.com Changed: Header Tag Controller v1.0 ?> <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> <link rel="stylesheet" type="text/css" href="stylesheet.css"> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="3" cellpadding="3"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> </table></td> <!-- body_text //--> <td width="50%" class="main" valign="top"><?php require DIR_WS_CLASSES . 'category_tree.php'; $osC_CategoryTree = new osC_CategoryTree; echo $osC_CategoryTree->buildTree(); ?></td> <td width="50%" class="main" valign="top"> <ul> <li><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . PAGE_ACCOUNT . '</a>'; ?></li> <ul> <li><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_EDIT, '', 'SSL') . '">' . PAGE_ACCOUNT_EDIT . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL') . '">' . PAGE_ADDRESS_BOOK . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL') . '">' . PAGE_ACCOUNT_HISTORY . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT_NEWSLETTERS, '', 'SSL') . '">' . PAGE_ACCOUNT_NOTIFICATIONS . '</a>'; ?></li> </ul> <li><?php echo '<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . PAGE_SHOPPING_CART . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . PAGE_CHECKOUT_SHIPPING . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '">' . PAGE_ADVANCED_SEARCH . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW) . '">' . PAGE_PRODUCTS_NEW . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_SPECIALS) . '">' . PAGE_SPECIALS . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_REVIEWS) . '">' . PAGE_REVIEWS . '</a>'; ?></li> <li><?php echo BOX_HEADING_INFORMATION; ?></li> <ul> <li><?php echo '<a href="' . tep_href_link(FILENAME_SHIPPING) . '">' . BOX_INFORMATION_SHIPPING . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_PRIVACY) . '">' . BOX_INFORMATION_PRIVACY . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_CONDITIONS) . '">' . BOX_INFORMATION_CONDITIONS . '</a>'; ?></li> <li><?php echo '<a href="' . tep_href_link(FILENAME_CONTACT_US) . '">' . BOX_INFORMATION_CONTACT . '</a>'; ?></li> </ul> </ul> </td> </table></td> </tr> </table> <!-- body_text_eof //--> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> <br> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> Now the line we need to add to catalog/includes/filenames.php is: // sitemap added define('FILENAME_SITEMAP', 'sitemap.php'); And that is that. By the way you can do a lot less work to sitemap.php (notice that greg says "suggested contents") and it will work, but you will not have the fancy osC menus displayed all over the place. It will only be plain sitemap html. Your choice. Hope that wasn't too hard to follow. Link to comment Share on other sites More sharing options...
molafish Posted May 12, 2004 Share Posted May 12, 2004 Now all you have to do is create a link somewhere in the header or footer file to the sitemap... (self-explanitary) Link to comment Share on other sites More sharing options...
mpiscopo Posted May 13, 2004 Share Posted May 13, 2004 Thanks Greg and Ian, This works great, it gives me the basic information I need. All I need to do is change the layout and appearance to finish it off. Appriciate the time both of you took to post here, I'm sure there are many other people who find this useful also. Link to comment Share on other sites More sharing options...
strictlypc Posted June 25, 2004 Share Posted June 25, 2004 Thanks, this is what i have been looking for! I originally had the categories hard coded. This code is much easier! Great job and thanks again! David Link to comment Share on other sites More sharing options...
devosc Posted June 25, 2004 Author Share Posted June 25, 2004 The above can now be found as an MS2-2.2 contribution here. "Any fool can know. The point is to understand." -- Albert Einstein Link to comment Share on other sites More sharing options...
Guest Posted September 3, 2004 Share Posted September 3, 2004 Hey Gregory. Great contribution Thanks ! One thing though... The sitemap works great for main categories, but returns different urls for sub-categories. eg) Sub-Cat Linked from main page url= /index.php/cPath/35_50 Breadcrumbs= home > Main Category > Sub-Category Linked from sitemap.php url= /index.php/cPath/50 Breadcrumbs= home > Sub-Category Page Title is missing also when linked from the sitemap page So, in essence, the proper page shows up, but because the url is different, the search engine bots will treat the pages as separate, duplicate content. Hope I made some sense Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.