Page 1 of 1

Top List (Tabs)

Posted: Tue 20. Apr 2004, 01:09
by captaincrash
Is there a solution to facilitate grounding of the nav_top_list tabs?? i.e. once you select the tab any sub level document leaves the tab active?

For an example see http://www.franthomas.com/

Posted: Thu 22. Apr 2004, 15:39
by captaincrash
Solved this as needed. Tab type menus can now be made to stay open as owners of a subcategory. Extra param. is added so it now reads {NAV_LIST_TOP:grounding:home_name:class_name} - check http://www.franthomas.com (work in progress) for an example;

..in content.func.inc.php around line 292

Code: Select all

// List based navigation with Top Level
if( ! ( strpos($content["all"],'{NAV_LIST_TOP')===false ) ) {
	$content["all"] = str_replace('{NAV_LIST_TOP}', css_list_top($content["struct"],$content["cat_path"],$content["cat_id"]), $content["all"]);
	// creates a list styled top nav menu | {NAV_LIST_TOP:grounding:home_name:class_name} | defaults 0:home:list_top
	$content["all"] = preg_replace('/\{NAV_LIST_TOP:(.*?):(.*?):(.*?)\}/e', 'css_list_top($content["struct"],$content["cat_path"],$content["cat_id"], "$1", "$2", "$3")', $content["all"]);
}
..and in front.func.inc.php around line 1142 replace the css_list_top function with this;

Code: Select all

function css_list_top($struct, $struct_path, $level, $grounding=0, $homelink="Home", $class="list_top", $link_to="index.php") {
	// returns list <div><ul><li></li></ul></div> of level 0
	// if $homelink is not empty it will also create a "Home" link
	// you can set $homelink to the name you like
	// predefined class for this menu is "list_top"	
	
	if(!trim($class)) $class = "list_top";
	$homelink = trim($homelink);
	$level = intval($level);
	$activated = 0; //no active list set
	$css_list = "";
    $catids = ",";
	
	//returns the complete top level AND home of NON hidden categories
	$top_struct = return_struct_level($struct, 0); 

	//return complete cat path as string
	while ($level) {
		$catids .= "$level,";
		$level = $struct[$level]["acat_struct"];
	}

	if(sizeof($top_struct)) {
		foreach($top_struct as $key => $value) {
		
			$thisactive = 0;
			$link  = $link_to."?";
			$link .= ($top_struct[$key]["acat_alias"]) ? html_specialchars($top_struct[$key]["acat_alias"]) : "id=".$key.",0,0,1,0,0";
			$css_list .= "    <li";
			
			if ($grounding) {
			  if (strstr($catids, ",".$top_struct[$key]["acat_id"].",")) $thisactive = 1;
			} else if($struct_path[$key]) $thisactive=1;

			if($thisactive) {
			  $css_list .= " id=\"".$class."_active\"";
  			  $activated = 1;
			}
						
			$css_list .= '><a href="'.$link.'"';
			$css_list .= (!$thisactive) ? "" : " id=\"".$class."_active_link\"";
			$css_list .= ' target="_top">'.html_specialchars($top_struct[$key]["acat_name"])."</a>";
			$css_list .= "</li>\n";
		}
	}
	
	if($homelink) {
		$css_list_home  = "    <li id=\"".$class. ((!$activated) ? "_home_active" : "_home") ."\">";
		$css_list_home .= '<a href="'.$link_to.'?id=0,0,0,1,0,0"';
		$css_list_home .= ($activated) ? "" : " id=\"".$class."_home_active_link\"";
		$css_list_home .= ' target="_top">'.html_specialchars($homelink)."</a>";
		$css_list_home .= "</li>\n";
		$css_list = $css_list_home . $css_list;
	}
	if($css_list) {
		$css_list = "<div id=\"".$class."\">\n  <ul id=\"".$class."_ul\">\n". $css_list ."  </ul>\n</div>";
	}
	return $css_list;
}

Posted: Mon 9. Aug 2004, 04:21
by jimtomas
This looks good on your site, however I am unable to recreate this on my site when using the tab style navigation.

In my one template I am using {NAV_LIST_TOP:0:home:list_top} for the tabbed navigation.

When visiting any sub levels the tabs do not reflect the location properly, defaulting to my "home" tab.