Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Happy new year.. and a little bit of help lol


tayl1684

Recommended Posts

Happy new year one and all!

 

I was hoping someone who is better at php than me (just about anyone) might be able to help with a bit of code that comes with the simple template contribution!

 

In sts there is a handy bit of code that allows you to use a dropdown menu. This is great except it doesnt add the oscsid to the path of the categories, which means that when you use it it drops the contents of the shopping cart. I'll post the code below maybe someone can tell me how to change it so that it adds a sid when it builds the url.

 

 

<?php

/*

$Id: sts_user_code.php,v 1.2 2004/02/05 05:57:21 jhtalk Exp jhtalk $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright ? 2003 osCommerce

 

Released under the GNU General Public License

*/

 

/*

 

Simple Template System (STS) - Copyright ? 2004 Brian Gallagher - [email protected]

 

*/

 

// PUT USER MODIFIED CODE IN HERE, SUCH AS NEW BOXES, ETC.

 

// The following code is a sample of how to add new boxes easily.

// Just uncomment block below and tweak for your needs!

// Use as many blocks as you need and just change the block names.

 

// $sts_block_name = 'newthingbox';

// require(STS_START_CAPTURE);

// require(DIR_WS_BOXES . 'new_thing_box.php');

// require(STS_STOP_CAPTURE);

// $template['newthingbox'] = strip_unwanted_tags($sts_block['newthingbox'], 'newthingbox');

 

 

$sts_block_name = 'catmenu';

require(STS_START_CAPTURE);

echo "\n<!-- Start Category Menu -->\n";

echo tep_draw_form('goto', FILENAME_DEFAULT, 'get', '');

echo tep_draw_pull_down_menu('cPath', tep_get_category_tree(), $current_category_id, 'onChange="this.form.submit();"');

echo "</form>\n";

echo "<!-- End Category Menu -->\n";

require(STS_STOP_CAPTURE);

$template['catmenu'] = $sts_block['catmenu'];

 

function tep_get_category_tree($parent_id = '0', $spacing = '', $exclude = '', $category_tree_array = '', $include_itself = false) {

global $languages_id;

 

if (!is_array($category_tree_array)) $category_tree_array = array();

if ( (sizeof($category_tree_array) < 1) && ($exclude != '0') ) $category_tree_array[] = array('id' => '0', 'text' => "Catalog");

 

if ($include_itself) {

$category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.language_id = '" . (int)$languages_id . "' and cd.categories_id = '" . (int)$parent_id . "'");

$category = tep_db_fetch_array($category_query);

$category_tree_array[] = array('id' => $parent_id, 'text' => $category['categories_name']);

}

 

$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 . "' and c.parent_id = '" . (int)$parent_id . "' order by c.sort_order, cd.categories_name");

while ($categories = tep_db_fetch_array($categories_query)) {

if ($exclude != $categories['categories_id']) $category_tree_array[] = array('id' => $categories['categories_id'], 'text' => $spacing . $categories['categories_name']);

$category_tree_array = tep_get_category_tree($categories['categories_id'], $spacing . ' ', $exclude, $category_tree_array);

}

 

return $category_tree_array;

}

 

?>

 

 

Many thanks in advance for any help you can offer

 

Ian

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...