Page 1 of 1
Tabs with three levels
Posted: Sat Jan 29, 2005 3:02 pm
by sayee3k1
Hello
I am new to PHP and wanted some help with the code.
I am displaying the categories in tabs and used the
contribution by Tom O'Neill
http://www.oscommerce.com/community/contributions,1023
this contribution has two levels and i wanted a third
level to be displayed on another row..........I went
thru the code several times and don't have a clue how
should i proceed.
I am trying to achieve the following:
when the user clicks on the second level link the
third level links appear on the next row and the
second level link which is clicked is disabled.
Any kind of suggestions will be helpful.
Thanks
Sai
Code
Posted: Sat Jan 29, 2005 3:05 pm
by sayee3k1
the code displaying the subcategories is
Code: Select all
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 .= ' ';
}
}
?>
<!-- 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] != ''){
show_subcategories($idї0]);
echo $subcategories_string;
}else{
echo " ";
}
?>
</td>
</tr>
</table>