WRAP_NAV_LIST_UL: includet level lift and class

If you've problems with unsupported - non official ;-) - functionalities use this forum please.
Post Reply
User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

WRAP_NAV_LIST_UL: includet level lift and class

Post by flip-flop »

{WRAP_NAV_LIST_UL:...:level, class}. The same like {NAV_LIST_UL: ....... but with a enclosed div container and included level lift.
If there is no navigation, no output is generated. (and no div wrapper).

E.g.:

Code: Select all

{WRAP_NAV_LIST_UL:F, 4,10, act_path, active : 0, my_class} -> output beginning at start ID 4 wrapped with my_class
{WRAP_NAV_LIST_UL:F,  ,10, act_path, active : 2, my_class} -> output beginning at level 2 wrapped with my_class
{WRAP_NAV_LIST_UL:F, 4,10, act_path, active : 0 }          -> output beginning at start ID 4 (no level lift)
{WRAP_NAV_LIST_UL:F, 4,10, act_path, active }              -> the same as above (no level lift)
{WRAP_NAV_LIST_UL:F,  ,10, act_path, active : 2 }          -> output beginning at level 2 (no wrapper class)
File: /template/inc_script/frontend_render/rt_wrap_nav_list_ul.php

Code: Select all

<?php
/* ==================================================================
 {WRAP_NAV_LIST_UL:...:level, class}. The same like {NAV_LIST_UL: ...
 but with a enclosed div container and included level lift
 If there is no navigation, no output is generated. (and no div wrapper).
 Including a parser for simple tags like [i] [u] [s] [b] [br] 
 If you need this, please uncomment around line 126 "$my_replace = local_html_parser($my_replace);"

 E.g.: 
{WRAP_NAV_LIST_UL:F, 4,10, act_path, active : 0, my_class} -> output beginning at start ID 4 wrapped with my_class
{WRAP_NAV_LIST_UL:F,  ,10, act_path, active : 2, my_class} -> output beginning at level 2 wrapped with my_class
{WRAP_NAV_LIST_UL:F, 4,10, act_path, active : 0 }          -> output beginning at start ID 4 (no level lift)
{WRAP_NAV_LIST_UL:F, 4,10, act_path, active }              -> the same as above (no level lift)
{WRAP_NAV_LIST_UL:F,  ,10, act_path, active : 2 }          -> output beginning at level 2 (no wrapper class)

 Direct call NAV_LIST_UL -> function buildCascadingMenu
 No default class: wrap_nlu_navi1 ??????

 File name: /template/inc_script/frontend_render/rt_wrap_nav_list_ul.php
 Forum: http://forum.phpwcms.org/viewtopic.php?p=111157#p111157

 Basic navigation: (c) Oliver Georgi, written for phpwcms
 Enhanced by (c) 08.11.08 Knut Heermann (flip-flop) http://planmatrix.de
===================================================================== */
// ------------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
   die("You Cannot Access This Script Directly, Have a Nice Day."); }
// ------------------------------------------------------------------



if( strpos($content['all'], '{WRAP_NAV_LIST_UL:') !== FALSE ) {

	function func_wrap_nav_list_ul($my_param) {

//		$my_class 		= 'wrap_nlu_navi1';		// default fallback class
		$my_class			= ''; 				 		// no default fallback class
		$div_before 		= '<div class';
		$div_behind 		= '</div>';
		
		$my_level_lift 	= false;
		$my_param 	 		= str_replace(' ','',$my_param); // kill all spaces
		
		// explode parameter for NAV_LIST_UL and the optional level and class name
		// $my_arr[0] = NAV_LIST_UL parameter
		// $my_arr[1] = optional own level and class name
		$my_arr = explode(":",$my_param); 
		
		$my_arr[0] = explode(",",$my_arr[0]);  // the NAV_LIST_UL parameter set
		// $my_arr[0][X] => nav_list_ul parameter array
		
		if (!empty($my_arr[1])) // ===== custom parameter are filled up?
		{ 
			$my_arr[1] = explode(",",$my_arr[1]); // cut out level and class
			// $my_arr[1][0] => level
			// $my_arr[1][1] => class
			
			// ===== level-lift parameter given? 
			if (!empty($my_arr[1][0]) and ($my_arr[1][0] > 0 ) )   // level
			{
				$my_level_lift = true;  // Yes level-lift ist active
				
				// ===== level lift: is this the right level?
				if ( isset($GLOBALS['LEVEL_ID'][$my_arr[1][0]]) ) 
				{ 
					// fill up the level
					$my_level_id = $GLOBALS['LEVEL_ID'][$my_arr[1][0]];
					
					// inject level lift ID into parameter string (No 2))
					$my_arr[0][1] = $my_level_id; 
				}
				else unset ($my_level_id);  // It is not the right level
			}
			
			
			
			// ===== custom class name given? 
			if (!empty($my_arr[1][1]))  // custom class name
			{
				$my_class = $my_arr[1][1]; // custom class name = yes -> set it up
			}
// kh			else {$my_class = 'wrap_nlu_navi1'; }	// custom class name = no -> default name
		
		} 	// =====END custom parameter are filled up?
		
// kh		else {$my_class = 'wrap_nlu_navi1'; }  // set to default ????
		
		// ===== set the parameter string for NAV_LIST_UL 
		$my_nlu_set = implode (",",$my_arr[0]); 



		// ======= set the wrapper code
		
		if (empty($my_class)) 	// is there any class name set?? 
		{ 
			$div_before = '';			// No class name set
			$div_behind = '';
		} else 	 $div_before .= '="'.$my_class.'">'; 	// Set your class

		
		// ======= catching the navigation 
		$string = '';
		
		// Direct call NAV_LIST_UL -> same as NAV_LIST_UL
		$string = trim(buildCascadingMenu($my_nlu_set)); 
		
		
		
		
		// ======= Output: Set the wrapper around and have a look to the level id 

		if ($string ) // is there any navi? 
		{
			$my_replace  = $div_before.LF.'	'.$string.LF.$div_behind;
			
			if ( $my_level_lift  and  !isset($my_level_id) ) // level-lift is set but we are not in the right level
			{
				$my_replace = '';
			} 
		}	
		else 	{ $my_replace = ''; }  // no navi found 

		// ----------------------------------------------------------------
		// Parsing simple Tags in link name like [i] [u] [s] [b] [br] .....
		// If you need it, please uncomment the next line
//		$my_replace = local_html_parser($my_replace);  
		// ----------------------------------------------------------------

	return $my_replace;
	}



	function local_html_parser($t) {
	// ---------------------------------------------------------------------------
	// Parse the $t and replace all possible values like you see in 
	// function html_parser (front.func.inc.php)

	//	$t = html_parser($t);

	// EDIT: 07/11/25 KH. (flip-flop) including simple Tags from the file 
	//  /include/inc_front/front.func.inc.php  and the  function html_parser($string) 
	// you can copy&paste what you want. 

	// ========== copy&paste ===========

	// typical html formattings
		$search[18]		= '/\[i\](.*?)\[\/i\]/is';			$replace[18]	= '<i>$1</i>';
		$search[19]		= '/\[u\](.*?)\[\/u\]/is';			$replace[19]	= '<u>$1</u>';
		$search[20]		= '/\[s\](.*?)\[\/s\]/is';			$replace[20]	= '<strike>$1</strike>';
		$search[21]		= '/\[b\](.*?)\[\/b\]/is';			$replace[21]	= '<strong>$1</strong>';

	// added simple [br] -> <br />
		$search[25]     = '/\[br\]/i';			$replace[25]    = '<br />';
	// ========== end copy&paste ========
	
		$t = preg_replace($search, $replace, $t);

	return $t;
	// ---------------------------------------------------------------------------
}


// And do it ==================================================================
$content["all"] = preg_replace('/{WRAP_NAV_LIST_UL:(.*?)}/e', 'func_wrap_nav_list_ul("$1")', $content["all"]);
// ============================================================================

}

?>
Knut
>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
design
Posts: 68
Joined: Thu 17. Feb 2005, 17:19

Re: WRAP_NAV_LIST_UL: includet level lift and class

Post by design »

Hello!
I try this menu, but I don't understand how it works...

I need this output:

<div id="menu">
<div class="my_class">
<ul class="act_path">
<li class="sub_no sub_ul_true sub_first_1"><a href="index.php?voice1">Voice1</a></li>
<li class="sub_no_2"><a href="index.php?voice2">Voice2</a></li>
<li class="sub_no_3"><a href="index.php?voice3">Voice3</a></li>
<li class="sub_no act_path active_4"><a href="index.php?voice4">Voice4</a></li>
</ul>
</div>
</div>

How can I have different class for every LI tag? So first tag LI is named "first" and is perfect. But, all the other LI tags are "sub_no"... I would like the second is named "second" or "2", and so on...

Is it possible with WRAP NAV LIST UL? Thanks!
User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

Re: WRAP_NAV_LIST_UL: includet level lift and class

Post by flip-flop »

This navigation and his parameter set are the same like - NAV_LIST_UL
- NAV_LIST_UL -basics

@string $parameter =
"menu_type, start_id, max_level, class_path, class_active, ul_id_name, wrap_ul_div(0 = off, 1 = <div>, 2 = <div id="">), wrap_link_text(<em>|</em>)"

In your case:

Code: Select all

{WRAP_NAV_LIST_UL:F, , , act_path, active, id : 0, my_class}
menu_type: F
start_id: root (blank=0)
max_level: all (blank)
class_path: act_path
class_active: active
ul_id_name: id
: 0 = no level lift
: my_class = wrapper class name

Output e.g.:

Code: Select all

<div id="menu">
 <div class="my_class">
  <ul id="id_0" class="act_path">
   <li id="li_id_1" class="sub_no sub_ul_true sub_first"><a href="index.php?voice1">Voice1</a></li>
   <li id="li_id_4" class="sub_no"><a href="index.php?voice2">Voice2</a></li>
   <li id="li_id_2" class="sub_no"><a href="index.php?voice3">Voice3</a></li>
   <li id="li_id_3" class="sub_no act_path active"><a href="index.php?voice4">Voice4</a></li>
  </ul>
 </div>
</div>
Id´s = category id´s.

Knut
>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
design
Posts: 68
Joined: Thu 17. Feb 2005, 17:19

Re: WRAP_NAV_LIST_UL: includet level lift and class

Post by design »

it's great! fantastic! :D
Thank you so much!
photojo
Posts: 713
Joined: Wed 15. Nov 2006, 20:02
Location: Regensburg, Germany
Contact:

Re: WRAP_NAV_LIST_UL: includet level lift and class

Post by photojo »

Hi,

habe folgende Struktur

Navigationspunkt 1
---Unternavigationspunkt 1
---Unternavigationspunkt 2
---Unternavigationspunkt 3

Navigationspunkt 2
---Unternavigationspunkt 1
---Unternavigationspunkt 2
---Unternavigationspunkt 3

Bisher habe ich oben die Hauptnavigation gehabt und links dann die entsprechenden Untermenüs und zwar so ...

Code: Select all

<div class="nlu_horiz1"><ul class="act_path">
 <li class="sub_no"><a href="index.php?home">home</a></li>
</ul>{NAV_LIST_UL:F,ID,1,act_path,active}</div>
</div>
<div id="left">

[PHP]
if(isset($GLOBALS['LEVEL_ID'][1])) {
$level_id = $GLOBALS['LEVEL_ID'][1];
echo '<div class="nlu_navi1">'.LF;
echo '{NAV_LIST_UL:F,'.$level_id.',,act_path,active}';
echo '</div>';
}
[/PHP]

</div>
Das geht auch so.

Nun habe ich mich um WRAP_NAV_LIST_UL angenommen und wollte das gleiche realisieren, und zwar so ...

Code: Select all

<div id="header">
{WRAP_NAV_LIST_UL:FP, , , act_path, active, id : 0, nlu_horiz1}

</div>
<div id="left">
{WRAP_NAV_LIST_UL: *** WAS MUSS DA HIN? ***}</div>
Vielen Dank, Jo
User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

Re: WRAP_NAV_LIST_UL: includet level lift and class

Post by flip-flop »

Code: Select all

{WRAP_NAV_LIST_UL:F,  ,10, act_path, active : 2, my_class} -> output beginning at level 2 wrapped with my_class
also

Code: Select all

{WRAP_NAV_LIST_UL:F, , , act_path, active : 1, nlu_navi1} -> Ausgabe beginnend im Level 1 umschlossen mit der Klasse nlu_navi1
>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
photojo
Posts: 713
Joined: Wed 15. Nov 2006, 20:02
Location: Regensburg, Germany
Contact:

Re: WRAP_NAV_LIST_UL: includet level lift and class

Post by photojo »

Hi nochmal,

habe nun diesen CODE

Code: Select all

<div id="header">
{WRAP_NAV_LIST_UL:FP, ,10 , act_path, active, id : 0, nlu_horiz1}
</div>

<div id="left">
{WRAP_NAV_LIST_UL:F, , , act_path, active : 1, nlu_navi1}
</div>
Mir werden die Untermenüs gar nicht angezeigt.

Liegt das wohl an diesem Problem: In der Sitemap sehe ich zwar meine ganze Struktur (siehe oben).
Wenn ich aber auf den Untermenüpunkt1 klicke, komme ich nur zum übergeordnetem Menüpunkt. Ich checke gar nichts mehr?

Jo
Post Reply