Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Strange category / cPath url issue


janetgot

Recommended Posts

Posted

I have a strange issue on http://hellynewengland.com... if I am on the homepage and mouse over my navigation menu, the categories all show the correct cPaths.

For example, my mens category is: http://www.hellynewengland.com/index.php?cPath=1

 

But if I go to a subcategory page, for example, http://www.hellynewengland.com/index.php?cPath=1_81 and then click through to another page, it seems that the cPath is holding on to the subcategory number. So if I go to Womens from here, it goes to http://www.hellynewengland.com/index.php?cPath=1_81_22, when it should go to http://www.hellynewengland.com/index.php?cPath=22

 

This is a problem, because we're using STS and have custom templates for the pages, which is now not showing up depending on where you have clicked first.

 

Has anybody seen this before and can you point me to where I need to look to address this issue? My categories page is heavily modified, but I'm not sure where to look in it, but I'll post it here in case that helps.

 

Thanks so much!

Janet

 

Here's the includes/boxes/categories page:

<?php

/*

$Id: show_subcategories.php,v 1.0 2003/01/08 10:37:00 Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com/

 

Based on: main_categories.php Ver. 1.0 by Gustavo Barreto

 

History: 1.0 Creation

 

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- this is for older snapshots pre-November 2002

/* 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 . '_' : ''))

;

} */

// Function used for post November 2002 snapshots

function tep_show_category($counter) {

global $foo, $categories_string, $id;

 

for ($a=0; $a<$foo[$counter]['level']; $a++) {

$categories_string .= " ";

}

}

}

 

?>

<!-- show_subcategories //-->

<tr>

<td class="infoBox_left">

 

<?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, false, true);

 

//////////

// 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')); used for older snapshots

$status = tep_db_num_rows(tep_db_query('describe ' . TABLE_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)

{

$temp_cPath_array = $cPath_array; //Johan's solution - kill the array but save it for the rest of the site

unset($cPath_array);

 

$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') . '" class="menusubcateg">' . '   ' . tep_image(DIR_WS_IMAGES . 'pointer_blue_light.gif', '') . $subcategories['categories_name'] . '</a>' . " ";

} // if

} // While Interno

$info_box_contents[$row] = array('align' => 'left',

'params' => 'class="smallText" width="125" valign="top"',

'text' => '' . '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '" class="menucateg"><b>' . ' ' . tep_image(DIR_WS_IMAGES . 'pointer_blue.gif', '') . $categories['categories_name'] . '</b></a>' . $text_subcategories);

$col ++;

if ($col > 0)

{

$col = 0;

$row ++;

}

$cPath_array = $temp_cPath_array; //Re-enable the array for the rest of the code

}

}

//new infoBox($info_box_contents, true);

new noborderBox2($info_box_contents, true);

 

 

?>

</td>

</tr>

<!-- show_subcategories_eof //-->

  • 3 weeks later...
Posted

I'm still trying to fix this issue on my site... digging deeper, the categories.php page is part of the Show Categories contribution. I recently added a third level to my subcategories, and was wondering if that was the problem... I removed those 3rd level subcategories, but I still have the problem...

 

Can somebody tell me where in the files the menu is calling the subcategory? And perhaps what I can tweak so that the cPath clears the old subcategory out of the link? Or perhaps suggest another way to show all my subcategories in my left nav menu? Perhaps Dynamenu?

 

Thanks for any help...

 

Janet

Archived

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

×
×
  • Create New...