Tabs with three levels

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sayee3k1
Forum Newbie
Posts: 20
Joined: Sat Feb 14, 2004 5:41 pm

Tabs with three levels

Post 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
sayee3k1
Forum Newbie
Posts: 20
Joined: Sat Feb 14, 2004 5:41 pm

Code

Post 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&#1111;$counter]&#1111;'name'];
	
	$subcategories_string .= '</a> ';
	
	if ($fooa&#1111;$counter]&#1111;'next_id']) &#123;
		$subcategories_string .= '| ';
		show_subcategories($fooa&#1111;$counter]&#1111;'next_id']);
	&#125;else&#123;
		$subcategories_string .= '&nbsp;';
	&#125;
&#125;
?>

<!-- subcategories //-->
<table border="0" cellspacing="0" cellpadding="4" WIDTH="100%">
<tr class="headerNavigation"><td ALIGN="CENTER" class="headerNavigation">
<?php
	if ($cPath) &#123;
		$subcategories_string = '';
		$new_path = '';
		$id = split('_', $cPath);
		reset($id);
		while (list($key, $value) = each($id)) &#123;
			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) &#123;
				$new_path .= $value;
				while ($row = tep_db_fetch_array($subcategories_query)) &#123;
					$fooa&#1111;$row&#1111;'categories_id']] = array(
						'name' => $row&#1111;'categories_name'],
						'parent' => $row&#1111;'parent_id'],
						'level' => $key+1,
						'path' => $new_path . '_' . $row&#1111;'categories_id'],
						'next_id' => false
					);
					if (isset($prev_id)) &#123;
						$fooa&#1111;$prev_id]&#1111;'next_id'] = $row&#1111;'categories_id'];
					&#125;
	
					$prev_id = $row&#1111;'categories_id'];
					
					if (!isset($first_id)) &#123;
						$first_id = $row&#1111;'categories_id'];
					&#125;
	
					$last_id = $row&#1111;'categories_id'];
				&#125;
				$fooa&#1111;$last_id]&#1111;'next_id'] = $fooa&#1111;$value]&#1111;'next_id'];
				$fooa&#1111;$value]&#1111;'next_id'] = $first_id;
				$new_path .= '_';
			&#125; else &#123;
				break;
			&#125;
		&#125;
	&#125;

	if ($id&#1111;0] != '')&#123;
		show_subcategories($id&#1111;0]); 
		echo $subcategories_string;
	&#125;else&#123;
		echo "&nbsp;";
	&#125;

?>
</td>
</tr>
</table>
Post Reply