Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

To Show Subcategories


arik

Recommended Posts

Hi!

The code:

<?php
function tep_show_mysubcategories($parentid, $cpath) {
 global $mysubcategories_string, $languages_id, $HTTP_GET_VARS;

// Get all categories

 $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 = " . $parentid . " 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))  {

   $mysubcategories_string .= '<a href="';
   $cPath_new = $cpath;
   $cPath_new_text = "cPath="  . $categories['parent_id'] . "_" . $categories['categories_id'];
   $mysubcategories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new_text);
   $mysubcategories_string .= '">';
   $mysubcategories_string .= $categories['categories_name'];
   $mysubcategories_string .= '</a>';
   $mysubcategories_string .= '<br>';
 }

}

?>

<ul>
<?php
   tep_show_mysubcategories(5,'');
   echo   $mysubcategories_string;
?>
</ul>
<ul>
<?php
   tep_show_mysubcategories(1,'');
   echo   $mysubcategories_string;
?>
</ul>

 

Brings up:

 

 

<ul>

<a href=...//index.php?cPath=5_8>Sub5_8</a><br>

<a href=...//index.php?cPath=5_9>Sub5_9</a><br>

</ul>

 

<ul>

<a href=...//index.php?cPath=5_8>Sub5_8</a><br>

<a href=...//index.php?cPath=5_9>Sub5_9</a><br>

<a href=...//index.php?cPath=1_10>Sub1_10</a><br>

<a href=...//index.php?cPath=1_11>Sub1_11</a><br>

</ul>

 

How can I get results like this:

 

<ul>

<a href=...//index.php?cPath=5_8>Sub5_8</a><br>

<a href=...//index.php?cPath=5_9>Sub5_9</a><br>

</ul>

 

<ul>

<a href=...//index.php?cPath=1_10>Sub1_10</a><br>

<a href=...//index.php?cPath=1_11>Sub1_11</a><br>

</ul>

 

Thanks in advance

Link to comment
Share on other sites

hi,

 

will this code, when hovering over a 'category' show sub-categories?

 

view here: www.ronzsmokinwood.com

 

if so, in what file & and where would i place this code?

 

 

thanks in advance,

 

ron-

Link to comment
Share on other sites

hi,

 

will this code, when hovering over a 'category' show sub-categories?

 

view here: www.ronzsmokinwood.com

 

if so, in what file & and where would i place this code?

 

 

thanks in advance,

 

ron-

 

Yeah, but it's not ready yet.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...