Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

HI

Can anyone solve this puzzel,

 

I have installed the Category with sub category contribution

 

I am able to see the categories but i am not able to see any sub categories below that...

 

 

this is the code i have in my header.php file

 

<?php include(DIR_WS_INCLUDES . 'categories_tab.php'); ?>

 

and in my categories_tab.php file

 

<?php

/*

 $Id: categories.php,v 1.1.1.1 2003/02/25 02:59:49 root Exp $



 osCommerce, Open Source E-Commerce Solutions

 [url=http://www.oscommerce.com]http://www.oscommerce.com[/url]



 Copyright (c) 2002 osCommerce



 Released under the GNU General Public License

*/





function show_category_tabs($counter) 

{

global $foo, $categories_string, $id, $HTTP_GET_VARS;

if ($foo[$counter]['parent'] == 0) {

 $cPath_new = 'cPath=' . $counter;

}

if ($HTTP_GET_VARS['cPath'] != 0){

 $base = substr($HTTP_GET_VARS['cPath'], 0, strpos($HTTP_GET_VARS['cPath'], '_'));

 if ($counter == $HTTP_GET_VARS['cPath']) {

	 $onpage = 1;

 } elseif ($counter == $base) {

	 $onpage = 1;

 }

}



if ($onpage) {

 $categories_string .= '<td valign="top" class="headerNavigation">';

} else {

 $categories_string .= '<td valign="top" class="inactiveNavigation">';

} 	 



$categories_string .= tep_image(DIR_WS_IMAGES . 'trans_corner_left.gif', ''); 

$categories_string .= '</td>';

if ($onpage) {

 $categories_string .= '<td valign="top" class="headerNavigation">';

} else {

 $categories_string .= '<td valign="top" class="inactiveNavigation">';

} 	 



$categories_string .= '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td valign="top" bgcolor="#ffffff">';

$categories_string .= tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '');

$categories_string .= '</td></tr><tr><td valign="top" bgcolor="#C0C0C0">';

$categories_string .= tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '');

$categories_string .= '</td></tr></table><a href="';

$categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new);

if ($onpage) {

 $categories_string .= '"  class="headerNavigation">';

} else {

 $categories_string .= '" class="inactiveNavigation">';

}

// display category name

$categories_string .= $foo[$counter]['name'];



$categories_string .= '</a>  </td>';

if ($onpage) {

 $categories_string .= '<td valign="top" class="headerNavigation">';

} else {

 $categories_string .= '<td valign="top" class="inactiveNavigation">';

} 	 



$categories_string .= tep_image(DIR_WS_IMAGES . 'trans_corner_right.gif', '');

$categories_string .= '</td>';



if ($foo[$counter]['next_id']) {

 $onpage = 0;

 show_category_tabs($foo[$counter]['next_id']);

}

}

?>





<?php

function show_subcategories($counter) 

{

global $fooa, $subcategories_string, $id, $HTTP_GET_VARS;

$cPath_new = 'cPath=' . $fooa[$counter]['path'];



$subcategories_string .= '<a href="';

$subcategories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new);

$subcategories_string .= '"  class="headerNavigation">';



// display category name

$subcategories_string .= $fooa[$counter]['name'];



$subcategories_string .= '</a> ';



if ($fooa[$counter]['next_id']) {

 $subcategories_string .= '| ';

 show_subcategories($fooa[$counter]['next_id']);

}else{

 $subcategories_string .= ' ';

}



}

?>





<!-- categories //-->

<table border="0" cellspacing="0" cellpadding="0" bgcolor="#000080">

<tr>

<?php

// Always add the home link first

$categories_string = '';

if (!$cPath) {

 $onpage = 1;

}

if ($onpage) {

 $categories_string .= '<td valign="top" class="headerNavigation">';

} else {

 $categories_string .= '<td valign="top" class="inactiveNavigation">';

} 	 



$categories_string .= tep_image(DIR_WS_IMAGES . 'trans_corner_left.gif', ''); 

$categories_string .= '</td>';

if ($onpage) {

 $categories_string .= '<td valign="top" class="headerNavigation">';

} else {

 $categories_string .= '<td valign="top" class="inactiveNavigation">';

} 	 



$categories_string .= '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td valign="top" bgcolor="#ffffff">';

$categories_string .= tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '');

$categories_string .= '</td></tr><tr><td valign="top" bgcolor="#C0C0C0">';

$categories_string .= tep_image(DIR_WS_IMAGES . 'pixel_trans.gif', '');

$categories_string .= '</td></tr></table><a href="';

$categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new);

if ($onpage) {

 $categories_string .= '"  class="headerNavigation">';

} else {

 $categories_string .= '" class="inactiveNavigation">';

}

// display category name

$categories_string .= "Home";



$categories_string .= '</a>  </td>';

if ($onpage) {

 $categories_string .= '<td valign="top" class="headerNavigation">';

} else {

 $categories_string .= '<td valign="top" class="inactiveNavigation">';

} 	 



$categories_string .= tep_image(DIR_WS_IMAGES . 'trans_corner_right.gif', '');

$categories_string .= '</td>';



if ($foo[$counter]['next_id']) {

 $onpage = 0;

 show_category_tabs($foo[$counter]['next_id']);

}





// start the tabs

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

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

 $foo[$categories['categories_id']] = array(

	 'name' => $categories['categories_name'],

	 'parent' => $categories['parent_id'],

	 'level' => 0,

	 'path' => $categories['categories_id'],

	 'next_id' => false

 );



 if (isset($prev_id)) {

	 $foo[$prev_id]['next_id'] = $categories['categories_id'];

 }



 $prev_id = $categories['categories_id'];



 if (!isset($first_element)) {

	 $first_element = $categories['categories_id'];

 }

}



show_category_tabs($first_element); 

echo $categories_string;



?>

</tr>

</table>

         

<!-- categories_eof //-->





<!-- subcategories //-->

<table border="0" cellspacing="0" cellpadding="4" WIDTH="100%">

<tr class="headerNavigation"><td ALIGN="CENTER" class="headerNavigation">



 <?php

if ($cPath) {

 $subcategories_string = '';

 $new_path = '';

 $id = split('_', $cPath);

 reset($id);

 while (list($key, $value) = each($id)) {

	 unset($prev_id);

	 unset($first_id);

	 $subcategories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . $value . "' and c.categories_id = cd.categories_id and cd.language_id='" . $languages_id ."' order by sort_order, cd.categories_name");

	 $subcategory_check = tep_db_num_rows($subcategories_query);

	 if ($subcategory_check > 0) {

   $new_path .= $value;

   while ($row = tep_db_fetch_array($subcategories_query)) {

  	 $fooa[$row['categories_id']] = array(

     'name' => $row['categories_name'],

     'parent' => $row['parent_id'],

     'level' => $key+1,

     'path' => $new_path . '_' . $row['categories_id'],

     'next_id' => false

  	 );

  	 if (isset($prev_id)) {

     $fooa[$prev_id]['next_id'] = $row['categories_id'];

  	 }



  	 $prev_id = $row['categories_id'];

  	 

  	 if (!isset($first_id)) {

     $first_id = $row['categories_id'];

  	 }



  	 $last_id = $row['categories_id'];

   }

   $fooa[$last_id]['next_id'] = $fooa[$value]['next_id'];

   $fooa[$value]['next_id'] = $first_id;

   $new_path .= '_';

	 } else {

   break;

	 }

 }

}



if ($id[0][0] != ''){

 show_subcategories($id[0][0]); 

 echo $subcategories_string;

}else{

 echo " ";

}



?>

</td>

</tr>

</table>

         

<!-- subcategories_eof //-->

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...