Menu déroulant

Pour WOLF

PERCIFORMES!

Welcome to the universe of Perciformes - perch-like fish that include the world famous Suckerfish

Hello. You have found an example page for Suckerfish Dropdowns. Under the hood you will find some nice structured HTML, a smattering of CSS and a teensy bit of JavaScript (that's just 12 lines of it). It's lightweight, it's accessible, it's cross-compatible.

Suckerfish Dropdowns are brought to you by Patrick Griffiths, Dan Webb and the letter C. To find out more about Suckerfish Dropdowns, check out the article in HTML Dog. To find out more about perch-like fishes, give Google a try.

Something else that might (possibly) be of interest (maybe) is that this page has an elastic layout. Try increasing your browser's text size setting and watch that layout grow! It's just like those toys that expand when you put them in water. Only without the water. And with more HTML. And CSS. Oh forget it. It's not really like them at all.

Go on. Visit HTML Dog

La fonction PHP

<?php
function displayChildren($page, $current, $startmenu = true, $limits = null) {
	if ($limits != null && array_key_exists($page->slug, $limits)) {
		$arr = array('order' => 'position ASC, published_on DESC', 'limit' => $limits[$page->slug]);
	} else
		$arr = array('order' => 'position ASC, published_on DESC');
	if ($page && count($page->children()) > 0) {
		echo ($startmenu) ? '<ul>' : '';
		foreach($page->children($arr) as $menu) :
		$daddy = (count($menu->children()) > 0 &&  $menu->level() > 1) ? ' class="daddy"' : null;
			echo '<li><a href="'. $menu->url() .'"'.  $daddy .'>'. $menu->title() .'</a>';
				displayChildren($menu, $current, true, $limits);
				echo '</li>';
			endforeach;
		echo ($startmenu) ? '</ul>' : '';
	}
}
?>

Affichage du menu

<div id="container">
	<h3>Pour WOLF</h3>
	<?php
		$page = $this->find('/');
		echo '<ul id="nav">';
		echo '<li>'.$page->link($page->title, (in_array($page->slug, explode('/', $this->url)) ? ' class="current"': null)).'</li>';
		echo displayChildren($page, $this, false);
		echo '</ul>';
	?>
</div>

Code CSS et JS

Entre HEAD et /HEAD

<style type="text/css">
#container {
	width: 36em;
	background: #F4ECD9;
	text-align: left;
	border: 1px solid #eda;
	margin: 0 auto;
	}

#nav, #nav ul {
	float: left;
	width: 36em;
	list-style: none;
	line-height: 1;
	background: white;
	font-weight: bold;
	padding: 0;
	border: solid #eda;
	border-width: 1px 0;
	margin: 0 0 1em 0;
	}

#nav a {
	display: block;
	width: 8em;
	w\idth: 6em;
	color: #7C6240;
	text-decoration: none;
	padding: 0.25em 2em;
	}

#nav a.daddy {
	text-decoration: line-through;
	}

#nav li {
	float: left;
	padding: 0;
	width: 8em;
	}

#nav li ul {
	position: absolute;
	left: -999em;
	height: auto;
	width: 14.4em;
	w\idth: 13.9em;
	font-weight: normal;
	border-width: 0.25em;
	margin: 0;
	}

#nav li li {
	padding-right: 1em;
	width: 13em
	}

#nav li ul a {
	width: 13em;
	w\idth: 9em;
	}

#nav li ul ul {
	margin: -1.75em 0 0 14em;
	}

#nav li:hover ul ul, #nav li:hover ul ul ul, #nav li.sfhover ul ul, #nav li.sfhover ul ul ul {
	left: -999em;
	}

#nav li:hover ul, #nav li li:hover ul, #nav li li li:hover ul, #nav li.sfhover ul, #nav li li.sfhover ul, #nav li li li.sfhover ul {
	left: auto;
	}

#nav li:hover, #nav li.sfhover {
	background: #eda;
	}
</style>

<script type="text/javascript"><!--//--><![CDATA[//><!--
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
//--><!]]></script>