Return to Snippet

Revision: 43648
at March 28, 2011 22:42 by orionrush


Updated Code
<?php if (!defined('SITE')) exit('No direct script access allowed');
/**
*
* flat Suckerfish menu
* 
* @version" 0.1
* @author: Vaska
* @author: orionrush
* @use: 1 - Save this clip as plugin.suckerMenu.php and place it in ndxz-studio/site/plugin 
* @use: 2 -in your site template (ndxz-studio/site/your-template-name/index.php) replace <plug:front_index /> with <plug:suckerMenu />
* @inspiration: http://www.htmldog.com/articles/suckerfish/dropdowns/
*	
**/

function suckerMenu()
{
	$OBJ =& get_instance();
	global $rs;

	$pages = $OBJ->db->fetchArray("SELECT id, title, url, 
		section, sec_desc, sec_disp, year, secid    
		FROM ".PX."objects, ".PX."sections 
		WHERE status = '1' 
		AND hidden != '1' 
		AND section_id = secid  
		ORDER BY sec_ord ASC, ord ASC");
		
	if (!$pages) return 'Error with pages query';
	
	foreach($pages as $reord)
	{
		$order[$reord['sec_desc']][] = array(
			'id' => $reord['id'],
			'title' => $reord['title'],
			'url' => $reord['url'],
			'year' => $reord['year'],
			'secid' => $reord['secid'],
			'disp' => $reord['sec_disp']);
	}
	
	$s = '';
	$s .= "<ul id='suckerNav'>\n";
	foreach($order as $key => $out)
	{
		
		if ($out[0]['disp'] == 1) $s .= "<li class='section-title'>" . $key . "\n";
		
		//need to insert if else for cases where Display Section Title is off, where by we need a new ul section for the title-less section 		
		if ($out[0]['disp'] != 1) $s .= "<li>\n";
		$s .= "<ul>\n";
		foreach($out as $page)
		
			
			//adds the class noSectTitle to the first li element in ul sections where the user has turned off 'Dispaly Section Title'
			if ($out[0]['disp'] != 1){
				$active = ($rs['id'] == $page['id']) ? " class='active noSectTitle'" : " class='noSectTitle'";
				$s .= "<li$active><a href='" . BASEURL . ndxz_rewriter($page['url']) . "' onclick=\"do_click();\">" . $page['title'] . "</a></li>\n";
			}
			else {
				{
				$active = ($rs['id'] == $page['id']) ? " class='active'" : '';
				$s .= "<li$active><a href='" . BASEURL . ndxz_rewriter($page['url']) . "' onclick=\"do_click();\">" . $page['title'] . "</a></li>\n";
			}
		}
		
		$s .= "</ul>\n</li>\n";

	}
	$s .= "</ul>\n";
	

	
	return $s;
}

?>

Revision: 43647
at March 28, 2011 22:35 by orionrush


Initial Code
<?php if (!defined('SITE')) exit('No direct script access allowed');
/**
*
* flat Suckerfish menu
* 
* @version" 0.1
* @author: Vaska
* @author: orionrush
* @use: replace <plug:front_index /> in your with <plug:suckerMenu />
* @use: Save this clip as plugin.suckerMenu.php and place it in ndxz-studio/site/plugin 
* @inspiration: http://www.htmldog.com/articles/suckerfish/dropdowns/
*	
**/

function suckerMenu()
{
	$OBJ =& get_instance();
	global $rs;

	$pages = $OBJ->db->fetchArray("SELECT id, title, url, 
		section, sec_desc, sec_disp, year, secid    
		FROM ".PX."objects, ".PX."sections 
		WHERE status = '1' 
		AND hidden != '1' 
		AND section_id = secid  
		ORDER BY sec_ord ASC, ord ASC");
		
	if (!$pages) return 'Error with pages query';
	
	foreach($pages as $reord)
	{
		$order[$reord['sec_desc']][] = array(
			'id' => $reord['id'],
			'title' => $reord['title'],
			'url' => $reord['url'],
			'year' => $reord['year'],
			'secid' => $reord['secid'],
			'disp' => $reord['sec_disp']);
	}
	
	$s = '';
	$s .= "<ul id='suckerNav'>\n";
	foreach($order as $key => $out)
	{
		
		if ($out[0]['disp'] == 1) $s .= "<li class='section-title'>" . $key . "\n";
		
		//need to insert if else for cases where Display Section Title is off, where by we need a new ul section for the title-less section 		
		if ($out[0]['disp'] != 1) $s .= "<li>\n";
		$s .= "<ul>\n";
		foreach($out as $page)
		
			
			//We need to add a class {like $active to the first li element in ul sections WITHOUT a heading
			if ($out[0]['disp'] != 1){
				$active = ($rs['id'] == $page['id']) ? " class='active noSectTitle'" : " class='noSectTitle'";
				$s .= "<li$active><a href='" . BASEURL . ndxz_rewriter($page['url']) . "' onclick=\"do_click();\">" . $page['title'] . "</a></li>\n";
			}
			else {
				{
				$active = ($rs['id'] == $page['id']) ? " class='active'" : '';
				$s .= "<li$active><a href='" . BASEURL . ndxz_rewriter($page['url']) . "' onclick=\"do_click();\">" . $page['title'] . "</a></li>\n";
			}
		}
		
		$s .= "</ul>\n</li>\n";
/*
		if ($out[0]['disp'] == 1) $s .= "</li>\n";
		if ($out[0]['disp'] != 1) $s .= "</li>\n";
*/

	}
	$s .= "</ul>\n";
	

	
	return $s;
}

?>

Initial URL


Initial Description


Initial Title
suckerMenu for Indexhibit

Initial Tags


Initial Language
PHP