Page 1 of 1

Menu appearance

Posted: Tue 18. Oct 2005, 16:50
by pieterbeulens
Hi there,

I am looking for a way in which I can display the menu for a website the way I want it. I would like to have the following: when user opens site, the 1st and 2nd level should be visible, but they should look different from each other. Then, when the user clicks a 2nd level menu entry, the third level should become visible, again different design from 1st and 2nd level. All the other 1st and 2nd level items should remain visible. When you click another 2nd level menu item, the first 3rd level menu item should disappear and the new 3rd level menu item should appear. I have this sytem working on a test page only using CSS, but without PHPWcms, but I was wondering how I can get this to work in PHPWcms too.

Thanks for your help!

Posted: Sat 5. Nov 2005, 20:16
by Oliver Georgi
You have develope your own menu. It's impossible to pre-develope everything.

Here is a sample used at http://www.bauhaus-award.de/

Included by {PHP:mymenufile.php}

Code: Select all

<?php

echo MyOwnNav($GLOBALS['LEVEL_ID'][1]);

function MyOwnNav($show_id) {

	$act_cat_id = intval($show_id);
	$nav = '';

	if($GLOBALS['content']['struct'][$GLOBALS['content']["cat_id"]]['acat_struct'] != 0) {
		$breadcrumb = get_breadcrumb($GLOBALS['content']["cat_id"], $GLOBALS['content']['struct']);
	}
	
	foreach($GLOBALS['content']['struct'] as $key => $value) {
	
		if($GLOBALS['content']['struct'][$key]["acat_struct"] == $act_cat_id && ($key != $act_cat_id) && !$GLOBALS['content']['struct'][$key]['acat_hidden']) {
			
			if($nav) {
				$nav .= "\n".'<div class="rowSpacer"><img src="img/leer.gif" alt="" width="1" height="1" /></div>';
				$nav .= "\n";
			}
			
			if($GLOBALS['content']["cat_id"] == $key || isset($breadcrumb[$key])) {
				$before = '<div id="active">';
				$after  = '</div>';
				$direct_before	= '';
				$direct_after	= '';
			} else {
				$before = '<div>';
				$after  = '</div>';
				$direct_before	= '';
				$direct_after	= '';
			}
			
			$nav .= $before;
			
			if(!$GLOBALS['content']['struct'][$key]["acat_redirect"]) {
				$nav .= '<a href="index.php?';
				if($GLOBALS['content']['struct'][$key]["acat_alias"]) {
					$nav .= html_specialchars($GLOBALS['content']['struct'][$key]["acat_alias"]);
				} else {
					$nav .= 'id='.$key.',0,0,1,0,0';
				}
				$nav .= '">';
			} else {
				$redirect = get_redirect_link($GLOBALS['content']['struct'][$key]["acat_redirect"], ' ', '');
				$nav .= '<a href="'.$redirect['link'].'"'.$redirect['target'].'>';
			}
			$nav .= $direct_before;
			$nav .= html_specialchars($GLOBALS['content']['struct'][$key]['acat_name']);;
			$nav .= $direct_after.'</a>'.$after;
		}
	}
	if($nav) {
		$nav  = "<div id=\"navlist\">\n".$nav;
		//$nav .= '<img src="img/leer.gif" alt="" width="1" height="55" />';
		//$nav .= '<div><a href="index.php?3rd">Review/R&uuml;ckblick 3rd&nbsp;Award&nbsp;2004</a></div>';
		$nav .= "\n</div>";
	}
	return $nav;
}

?>
Oliver