Hi folks - sorry I didn't get to post this last night. Here is the code for flyout menus and footer links as requested. I also had a function call all pages "in this section" meaning all children pages of the main section pages within the site, that would be shown on all pages within that branch of the site structure. I never got it to work very well, so I'd be interested if anybody has a good solution for that.
Here is the code for the footer menu. You'll note I'm explicitly suppressing some menu items that I moved to a toolbar. There must be a better way to do that than hard-coding them...
// Function to generate footer links
function page_footer_links($item_template = '[a][menu_title][/a]', $default_class = ' class="footer_default"', $current_class = ' class="footer_current"') {
global $database, $admin, $page_id, $page_trail, $default_link, $extra_sql, $extra_where_sql;
// Check just the top level
if (stristr($_SERVER['PHP_SELF'], "espanol")) {
$parent = 14;
} else {
$parent = 0;
}
$menu_number = '1';
// Query pages
$query_menu = $database->query("SELECT page_id,menu_title,page_title,link,target,level,visibility$extra_sql FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND $menu_number AND $extra_where_sql ORDER BY position ASC");
// Check if there are any pages to show
if($query_menu->numRows() > 0) {
// Loop through pages
while($page = $query_menu->fetchRow()) {
// Create vars
$vars = array('[class]', '[a]', '[/a]', '[menu_title]', '[page_title]');
// Work-out class
if($page['page_id'] == PAGE_ID) {
$class = $current_class;
} else {
$class = $default_class;
}
// Check if link is same as first page link, and if so change to WB URL
if($page['link'] == $default_link AND !INTRO_PAGE) {
$link = WB_URL;
} else {
$link = page_link($page['link']);
}
// Create values
$values = array($class, '<a href="'.$link.'" target="'.$page['target'].'">', '</a>', str_replace(" "," ",stripslashes($page['menu_title'])), stripslashes($page['page_title']));
// Replace vars with value and print
if ($page['menu_title'] != "Español") {
$mylinks[] = str_replace($vars, $values, $item_template);
}
// Generate sub-menu
}
// Print out links
$mylinks = implode(" . ", $mylinks);
echo $mylinks;
}
}[/color]
Here is the code for generating the flyout menu html:
// Function to generate main menu
function pdp_page_menu($parent = 0, $menu_number = 1, $item_template = '<li[class]>[a][menu_title][/a]', $menu_header = '<ul>', $menu_footer = '</ul>', $default_class = ' class="menu_default"', $current_class = ' class="menu_current"', $recurse = LEVEL) {
global $database, $admin, $page_id, $page_trail, $default_link, $extra_sql, $extra_where_sql;
// Check if we should add menu number check to query
if($parent == 0 || $parent == 14) {
$menu_number = "menu = '$menu_number'";
$item_template = '<td><ul><li[class]><h2>[a][menu_title][/a]</h2>';
$menu_header = '';
$menu_footer = '';
} else {
$menu_number = '1';
}
// Query pages
$query_menu = $database->query("SELECT page_id,menu_title,page_title,link,target,level,visibility$extra_sql FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND $menu_number AND $extra_where_sql ORDER BY position ASC");
// Check if there are any pages to show
if($query_menu->numRows() > 0) {
// Print menu header
echo $menu_header;
// Loop through pages
while($page = $query_menu->fetchRow()) {
if ($page['menu_title'] != 'Contactar' && $page['menu_title'] != 'Home' && $page['menu_title'] != 'Links' && $page['menu_title'] != 'Español' && $page['menu_title'] != 'Contact' && $page['menu_title'] != 'Links' && $page['menu_title'] != 'Sitemap' && $page['menu_title'] != 'Mapa del Sitio') { //
// Create vars
$vars = array('[class]', '[a]', '[/a]', '[menu_title]', '[page_title]');
// Work-out class
if($page['page_id'] == PAGE_ID) {
$class = $current_class;
} else {
$class = $default_class;
}
// Check if link is same as first page link, and if so change to WB URL
if($page['link'] == $default_link AND !INTRO_PAGE) {
$link = WB_URL;
} else {
$link = page_link($page['link']);
}
// Create values
$values = array($class, '<a href="'.$link.'" target="'.$page['target'].'">', '</a>', stripslashes($page['menu_title']), stripslashes($page['page_title']));
// Replace vars with value and print
echo str_replace($vars, $values, $item_template);
// Generate sub-menu
//if(isset($page_trail[$page['page_id']])) {
page_menu($page['page_id'], $menu_number, '<li[class]>[a][menu_title][/a]', '<ul>', '</ul>', $default_class, $current_class, $recurse-1);
//}
if ($parent == 0) {
echo "</li></ul></td>";
} else {
echo "</li>";
};
}
}
// Print menu footer
echo $menu_footer;
}
}[/color]
Call the above code like this:
<div id="menu"><table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<? pdp_page_menu(0, 1, '<li class="menu_main"[class]>[a][menu_title][/a]</li>', '', '', '', ' style="font-weight: bold;"'); ?>
</tr></table></div>[/color]
And finally, here is the CSS to make the menus do their thing (note you need csshover.htc to make IE work right):
<!--[if IE]>
<style type="text/css" media="screen">
body {
behavior: url(/css/csshover.htc);
font-size: 11px;
}
#menu ul li {float: left; width: 100%;}
#menu ul li a {height: 1%;}
</style>
<![endif]-->
#menu {
width: 543px;
z-index: 50;
position: absolute;
top: 37px;
left: 221px;
}
#menu td {
margin: 0px;
padding: 0px;
}
th {
text-align: left;
}
#menu ul {
list-style: none;
margin: 0px;
padding: 0px;
float: left;
}
#menu a, #menu h2 {
font: 11px tahoma, verdana, arial, helvetica, sans-serif;
display: block;
border: none;
margin: 0;
padding: 2px 3px;
}
#menu h2 {
color: #DDC877;
background-image: url(/images/button_bg.gif);
background-repeat: no-repeat;
text-transform: uppercase;
font-weight: bold;
padding-left: 10px;
padding-right: 10px;
padding-top: 20px;
padding-bottom: 23px;
}
#menu h2:hover {
color: #FFFFFF;
}
#menu a {
color: #DDC877;
background: #182829;
text-decoration: none;
font-weight: normal;
padding-left: 10px;
padding-right: 0px;
margin-right: 0px;
border-left: solid 1px #576568;
}
#menu h2 a {
padding: 0px;
border: none;
}
#menu h2 a:hover {
padding: 0px;
border: none;
background-color: #18252B;
}
#menu a:hover {
color: #ffffff;
background: #A51C36;
border-left: solid 1px #576568;
}
#menu a:focus {
color: #ffffff;
background: #A51C36;
border-left: solid 1px #576568;
}
#menu li {position: relative;}
#menu ul ul {
position: absolute;
z-index: 500;
width: 150px;
}
#menu ul ul ul {
position: absolute;
top: 4px;
left: 145px;
border-left: solid 1px #576568;
}
div#menu ul ul,
div#menu ul li:hover ul ul,
div#menu ul ul li:hover ul ul
{display: none;}
div#menu ul li:hover ul,
div#menu ul ul li:hover ul,
div#menu ul ul ul li:hover ul
{display: block;}
Hope this helps! Sorry this code has some extraneous junk in it!