NAV_HORIZ_DD:Typ,ID,Tiefe,li-id

TAG

{NAV_HORIZ_DD: Typ, ID, Ebenentiefe, li-ID}

@string $parameter = “menu type, start_id, max_level_depth, id for every li”

- Menu type:         H=Home on|off, P=Parent on|off
- start_id:          Where the output begins 
- max_level_depth:   Where the output ends
- id for ervery li:  class name

Erweiterungen in dieser Version:
- Allen Links im ersten Level ist die Klasse .first-level zugeordnet
- Wenn “Home” dargestellt erhält “Home” zusätzlich die Klasse .home
- Der aktive Link kann nun mit der Klasse .act_path über alle Ebenen verfolgt werden
- Der aktive Link wird mit der Klasse .active gekennzeichnet
- Der Menü-Typ H gibt “Home” mit der Klasse .home in der ersten Ebene aus
- Der Menü-Typ P zeigt auch das Elternelement von start_id.
- Die Kombination HP bei ID=0 gibt P den Vorrang.
- Update 20.11.2010 KH: Jedem UL wird ein Level mitgegeben.
- Update 18.11.2011 KH: Der title TAG zu jedem Link kann optional ausgegeben werden

Beispiel:

<div id="menu_container">
  {NAV_HORIZ_DD:H,0,2,id}
</div>

→ Menü beginnt ab Level 0 (Home) und ist tiefenbegrenzt auf zwei Level, home wird auch ausgegeben, jedes <li bekommt die ID mitgeliefert (<li id="li_id_X">).

  • Typ: H = Die Ebene Home wird zusätzlich dargestellt (in der ersten Ebene)
  • Typ: P = Das Elternelement wird dargestellt
  • Typ: HP = Home und die angegebene Ebene (Elternelement) werden dargestellt (bei id=0 Sonderfall → Home als einfaches Elternelement)
  • ID = Start-ID aus dem Kategoriebaum
  • Ebenetiefe = Anzahl Ebenen/Level tief
  • li-ID = Teil-Name der Klasse die jedem <li mitgegeben wird. An die Klasse wird die Kategorie-ID angehängt (li_ID_X).


PHP V1.1

In == CUSTOM VAR == können einige Klassennamen angepasst werden.

Dateiname: rt_nav_horiz_drop_down_v11.php

Ort: /template/inc_script/frontend_render/

rt_nav_horiz_drop_down_v11.php

<?php
/**
* **************************************************************************
* V1.1 05.03.2010 K.heermann http://planmatrix.de
*
* 25.07.07 horizontal drop-down with ID output -> NAVI HORIZONTAL DROP-DOWN
* Oliver Georgi
* http://www.phpwcms.de/forum/viewtopic.php?p=89743#89743
* 08.11.07 KH (flip-flop) Enhanced: Start[ID] {NAV_HORIZ_DD:ID}
* 28.04.08 KH (flip-flop) Enhanced: Level depth {NAV_HORIZ_DD:ID,Depth}
* http://www.phpwcms.de/forum/viewtopic.php?p=94688#94688
* 05.03.10 KH (flip-flop) Enhanced: Menu type, H&P, id for every li
* @string $parameter = "menu type, start_id, max_level_depth, id for ervery li"
*  - Menu type:        H=Home on|off, P=Parent on|off
*  - id for ervery li: class name
*
* TAG:      {NAV_HORIZ_DD:Menu type, Start-ID, Level depth, li id_name}
* E.g.:     {NAV_HORIZ_DD:H, 2, 3, id}
* Location: Put it into the file e.g.:
*           /template/inc_script/frontend_render/rt_nav_horiz_drop_down.php
* Switch in conf.inc.php: $phpwcms['allow_ext_render']  = 1;
* **************************************************************************
*/
// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
   die("You Cannot Access This Script Directly, Have a Nice Day.");
}
// ----------------------------------------------------------------
 
if( ! ( strpos($content["all"],'{NAV_HORIZ_DD')==false ) ) {
 
    $content["all"] = str_replace('{NAV_HORIZ_DD}','{NAV_HORIZ_DD:,0,100}',$content["all"]);  // For a simple call
    $content["all"] = preg_replace('/\{NAV_HORIZ_DD:(.*?)\}/e', 'buildNavi_horiz("$1");', $content["all"]);
}
 
 
 
//function buildNavi_horiz($start=0, $counter=0, $depth=0) {
function buildNavi_horiz($parameter='', $counter=0, $param='string') {
 
 
    // ====== CUSTOM VAR ==========================================
 
    $menu_class = 'pmenu';  // Menue Klassenname
 
    $a2 = ' first-level';   // The upper level  // Das erste Level
    $a3 = ' active';        // The active link  // Der aktive Link
//    $a4 = ' first-entry';   // The first entry in upper level  // Erster Eintrag im ersten Level
//    $a5 = ' last-entry';    // The last entry in upper level  // Letzter Eintrag im ersten Level
 
   // ====== CUSTOM VAR ENDE ======================================
 
 
    // only for the first call from extern
    // Nur fuer den ersten externen Aufruf
    if($param == 'string') {
 
        $parameter         = explode(',', $parameter);
 
        // first entry a digit or sign?  Only for compatibility to the older nav version
        // Erster Eintrag eine Zahl?  Nut fuer Kompatibilität mit aeltere Navi Version
        if (isset($parameter[0])  AND  (preg_match('/^[0-9]+$/i',$parameter[0])) ) {
 
            array_unshift ( $parameter, '' );  // Fill up array for $menu_type
        }
        $menu_type        = empty($parameter[0]) ? '' : strtoupper(trim($parameter[0]));
        $start_id        = empty($parameter[1]) ? 0  : intval($parameter[1]);
        $max_depth        = empty($parameter[2]) ? 0  : intval($parameter[2]-1);
        $level_id_name    = empty($parameter[3]) ? '' : trim($parameter[3]);
        $parent            = false; // do not show parent link
        $home            = false; // do not show home link
 
 
        switch($menu_type) {
                            // show parent level too - only in first line  [Parent]
            case 'P':        $parent = true;
                            break;
 
                            // Home in the first line  [Home] [Cat01] [Cat02] [Cat03]
            case 'HP':        $parent = true;
            case 'H':        $home     = true;
                            if($start_id == '0' AND $parent) $home = false;
                            break;
        }
 
    } else {  // for the inner call (recursive run)
 
        $menu_type        = $parameter[0];
        $start_id        = $parameter[1];
        $max_depth        = $parameter[2]-1;
        $level_id_name    = $parameter[3];
        $parent            = false; // do not show parent link
        $home            = false; // do not show home link
 
    }
 
 
    // ----- System var ----------------
    $t = array();
    $x = 0;
    // ---------------------------------
 
   $struct = getStructureChildData($start_id);  // Catch structure
 
 
   if($counter == 0) {
      $last = count($start_id) - 1;
 
      // ======== Only if you want the home link // Nur wenn Home gewuenscht
      if ($home) { // Home in the first line  [Home] [Cat01] [Cat02] [Cat03]
 
          $l  = '   <li '.
                            (($level_id_name) ? 'id="li_'.$level_id_name.'_0" ' : '').
                            'class="drop home'.$a2.$a4.
                            (($GLOBALS['content']['cat_id'] == 0)?$a3:'').
                            '">';
          $l .= get_level_ahref($start_id, ' class="home"') . '<span>'. html_specialchars($GLOBALS['content']['struct']['0']['acat_name']);
          $l .= '</span></a></li>';
          $t[] = $l;
      }
 
      // ======== Only if you want the parent link // Nur wenn der Eltern-Link gewuenscht
      if ($parent) { // Parent only in first line  [Parent]
 
          $struct = array();  // clear array  // Array leeren
          $struct[$start_id] = $GLOBALS['content']['struct'][$start_id];
     }
      // ========
 
   } else {
      $last = 0;
   }
 
 
 
   foreach($struct as $value) {
 
// Is it a active path ?      ========
// Ist dies der aktive Pfad ? ========
      if( isset($GLOBALS['LEVEL_KEY'][ $value['acat_id'] ]) ) {
         $p1 = ' act_path';
      } else {
         $s  = '';           // Reset $struct
         $p1 = '';
      }
 
// Only if there is a sub level     ========
// Nur wenn SubLevel vorhanden ist  ========
      if($GLOBALS['content']['cat_id'] == $value['acat_id']) {
         $a1 = ' act_path';  // Only for a direct call // Nur bei direktem Aufruf (FirstLevel active)
         $a3 = '';           // Not in use
      } else {               // If first level isn´t active // Wenn FirstLevel nicht aktiv
         $a1 = $p1;
         $a3 = '';
      }
 
// ==========================
 
      // -- <D01> -------------------------------------------------------------------
      // Preset level depth added
      // Ebenetiefenvorgabe hinzugefuegt
      //      $s = buildNavi_horiz($value['acat_id'], $counter+1);
 
      $parameter[1] = $value['acat_id'];  // start_id
 
//      if (($counter) < $depth) {$s = buildNavi_horiz($value['acat_id'], $counter+1, $depth, 'param_is_array');
      if (($counter) < $max_depth) {$s = buildNavi_horiz($parameter, $counter+1, 'param_is_array');
      }
      else {$s = '';}
      // -- <D01> -------------------------------------------------------------------
 
      // Set the active link class
      // Aktive Link Classe setzen
      ($GLOBALS['content']['cat_id'] == $value['acat_id']) ? $a3 = ' active': $a3 = '';
 
      if($s) {
         $g  = '<!--[if gte IE 7]><!--></a><!--<![endif]-->';
         $g .= $s;
         $g .= LF . str_repeat('   ', $counter);
 
         $class = $counter ? (' class="fly_ul '.$a1.$a3.'"') : (' class="drop_ul '.$a1.$a2.$a3.'"'); // Second level with active category
 
         $close_li = str_repeat('   ', $counter+1);
 
      } else {
         $g  = '</a>';
//         $class = ' class="sub_no'.$a1.$a3.'"';  // act_path auch im letzten activ link
         $class = ' class="sub_no'.$a3.'"';
        // -- <P01> -------------------------------------------------------------------
         // Only the first level if there is no sub level
         // Ausschlieszlich das erste Level wenn kein Sublevel vorhanden ist
         if ($counter == 0) {
            $class = ' class="sub_no'.$a1.$a2.'"';  // Set it, it is active or not // Es ist aktiv oder nicht
         // -- <P01> -------------------------------------------------------------------
         }
         $close_li = '';
      }
 
//    first li in block          =======
//    Erstes li im letzten Block =======
      if( $last && $last == $x ) {
         $enclose = ' class="horiz_enclose"';
      } elseif( $x || ($counter == 0 && $x == 0) ) {
         $enclose = '';
      } else {
         $enclose = ' class="horiz_enclose"';
      }
 
//    IDs for every li  ======= If you need the ID class, please uncomment/comment
//    IDs fuer jedes li ======= Wenn sie die ID Klassen benoetigen, bitte dekommentieren/kommentieren
//      $l  = str_repeat('   ', $counter+1) . '<li'. $class . ' id="cat-id_' . $value['acat_id'] . '">';
      if ($level_id_name)
         $l  = str_repeat('   ', $counter+1) . '<li'. $class . ' id="li_'.$level_id_name.'_'. $value['acat_id'] . '">';
      else
         $l  = str_repeat('   ', $counter+1) . '<li'. $class . '>';
 
      $l .= get_level_ahref($value['acat_id'], $enclose) . html_specialchars($value['acat_name']);
      $l .= $g;
 
 
      $l .=  $close_li . '</li>';
 
      $t[] = $l;
 
      $x++;
   }
 
   if($counter) {
      $A = LF . str_repeat('   ', $counter) . '<!--[if lte IE 6]><table><tr><td><![endif]-->';
      $B = LF . str_repeat('   ', $counter) . '<!--[if lte IE 6]></td></tr></table></a><![endif]-->';
   } else {
      $A = '';
      $B = '';
   }
 
 
   $t = implode(LF, $t);
   if($t) {
      $t =   $A . LF . str_repeat('   ', $counter) .   '<ul'.($counter?'':' id="'.$menu_class.'"').'>' . LF . $t . LF . str_repeat('   ', $counter) . '</ul>'.   $B ;
   }
 
/*
   // -- <E01> -------------------------------------------------------------------
   // EDIT: 07/11/25 KH. (flip-flop) including simple Tags in category headline 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>';
 
   // ========== end copy&paste ========
 
   $t = preg_replace($search, $replace, $t);
 
   // -- <E01> -------------------------------------------------------------------
*/
 
   return $t;
}
?>

<note important> WICHTIG!

Vor dem Einsatz der V1.1 bitte die vorherige NAV_HORIZ_DD deaktiviern
(die Datei in der Endung umbenennen oder löschen).

Z.B.: rt_nav_horiz_drop_down.php → rt_nav_horiz_drop_down.php_ </note>


PHP V1.2a

Update 20.11.2010 KH:

  • Jedem UL wird ein Level mitgegeben.
  • Aufruf mit {NAV_HORIZ_DD1:…….}

Update 16.12.2010 KH:

  • Alle ersten <li> bekommen zusätzlich die Klasse “sub_first” zugewiesen.


<ul class="level-2">
      <li class="sub_no sub_first" id="cat_33"><a href="ind .......
      <li class="fly_ul" id="cat_34"><a href="ind .......
      <ul class="level-3">
            <li class="sub_no sub_first" id="cat_41"><a href="ind .......
            <li class="sub_no" id="cat_43"><a href="ind .......
            ........

Typischer Aufruf:

<div class="hmenu">{NAV_HORIZ_DD1:,0,4,cat}</div>

In == CUSTOM VAR == können einige Klassennamen angepasst werden.

Dateiname: rt_nav_horiz_drop_down_v12.php

Ort: /template/inc_script/frontend_render/

rt_nav_horiz_drop_down_v12.php

<?php
/**
* **************************************************************************
* V1.2a  16.12.2010 K.heermann http://planmatrix.de
*
* 25.07.07 horizontal drop-down with ID output -> NAVI HORIZONTAL DROP-DOWN
* Oliver Georgi
* http://www.phpwcms.de/forum/viewtopic.php?p=89743#89743
* 08.11.07 KH (flip-flop) Enhanced: Start[ID] {NAV_HORIZ_DD:ID}
* 28.04.08 KH (flip-flop) Enhanced: Level depth {NAV_HORIZ_DD:ID,Depth}
* http://www.phpwcms.de/forum/viewtopic.php?p=94688#94688
* 05.03.10 KH (flip-flop) Enhanced: Menu type, H&P, id for every li
* @string $parameter = "menu type, start_id, max_level_depth, id for ervery li"
*  - Menu type:        H=Home on|off, P=Parent on|off
*  - id for ervery li: class name
* 16.12.10 KH (flip-flop) Enhanced: Every first <li> is marked with the
* class "sub_first"
*
* TAG:      {NAV_HORIZ_DD1:Menu type, Start-ID, Level depth, li id_name}
* E.g.:     {NAV_HORIZ_DD1:H, 2, 3, id}
* Location: Put it into the file e.g.:
*           /template/inc_script/frontend_render/rt_nav_horiz_drop_down_v11.php
* Switch in conf.inc.php: $phpwcms['allow_ext_render']  = 1;
* **************************************************************************
*/
// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
   die("You Cannot Access This Script Directly, Have a Nice Day."); }
// ----------------------------------------------------------------
 
if( ! ( strpos($content["all"],'{NAV_HORIZ_DD1')==false ) ) {
 
    $content["all"] = str_replace('{NAV_HORIZ_DD1}','{NAV_HORIZ_DD1:,0,100}',$content["all"]);  // For a simple call
    $content["all"] = preg_replace('/\{NAV_HORIZ_DD1:(.*?)\}/e', 'buildNavi_horiz1("$1");', $content["all"]);
}
 
 
 
//function buildNavi_horiz($start=0, $counter=0, $depth=0) {
function buildNavi_horiz1($parameter='', $counter=0, $param='string') {
 
 
    // ====== CUSTOM VAR ==========================================
 
    $menu_class = ' hmenu';  // Menu class name // Menue Klassenname
 
    $first_lev    = ' first-level';
    $act_path    = ' act_path';
    $active     = ' active';        // The active link  // Der aktive Link
   // ====== CUSTOM VAR ENDE ======================================
 
 
    // only for the first call from extern
    // Nur fuer den ersten externen Aufruf
    if($param == 'string') {
 
        $parameter         = explode(',', $parameter);
 
        // first entry a digit or sign?  Only for compatibility to the older nav version
        // Erster Eintrag eine Zahl?  Nur fuer Kompatibilität mit aeltere Navi Version
        if (isset($parameter[0])  AND  (preg_match('/^[0-9]+$/i',$parameter[0])) ) {
 
            array_unshift ( $parameter, '' );  // Fill up array for $menu_type
        }
        $menu_type        = empty($parameter[0]) ? '' : strtoupper(trim($parameter[0]));
        $start_id        = empty($parameter[1]) ? 0  : intval($parameter[1]);
        $max_depth        = empty($parameter[2]) ? 0  : intval($parameter[2]-1);
        $level_id_name    = empty($parameter[3]) ? '' : trim($parameter[3]);
        $parent            = false; // do not show parent link
        $home            = false; // do not show home link
 
 
        switch($menu_type) {
                            // show parent level too - only in first line  [Parent]
            case 'P':        $parent = true;
                            break;
 
                            // Home in the first line  [Home] [Cat01] [Cat02] [Cat03]
            case 'HP':        $parent = true;
            case 'H':        $home     = true;
                            if($start_id == '0' AND $parent) $home = false;
                            break;
        }
 
    } else {  // for the inner call (recursive run)
 
        $menu_type        = $parameter[0];
        $start_id        = $parameter[1];
        $max_depth        = $parameter[2]-1;
        $level_id_name    = $parameter[3];
        $parent            = false; // do not show parent link
        $home            = false; // do not show home link
 
    }
 
 
    // ----- System var ----------------
    $t = array();
    $x = 0;
    // ---------------------------------
 
   $struct = getStructureChildData($start_id);  // Catch structure
 
 
   if($counter == 0) {
      $last = count($start_id) - 1;
 
      // ======== Only if you want the home link // Nur wenn Home gewuenscht
      if ($home) { // Home in the first line  [Home] [Cat01] [Cat02] [Cat03]
 
          $l  = '   <li '.
                            (($level_id_name) ? 'id="'.$level_id_name.'_0" ' : '').
                            'class="drop home'.$first_lev.$a4.
                            (($GLOBALS['content']['cat_id'] == 0)?$active:'').
                            '">';
          $l .= get_level_ahref($start_id, ' class="home"') . '<span>'. html_specialchars($GLOBALS['content']['struct']['0']['acat_name']);
          $l .= '</span></a></li>';
          $t[] = $l;
      }
 
      // ======== Only if you want the parent link // Nur wenn der Eltern-Link gewuenscht
      if ($parent) { // Parent only in first line  [Parent]
 
          $struct = array();  // clear array  // Array leeren
          $struct[$start_id] = $GLOBALS['content']['struct'][$start_id];
     }
      // ========
 
   } else {
      $last = 0;
   }
 
 
   $first_li = ' sub_first';  // Init first <li> flag
 
   foreach($struct as $value) {
 
 
// ============
// dumpVar($value['acat_id']);
 
// Is it a active path ?      ========
// Ist dies der aktive Pfad ? ========
      if( isset($GLOBALS['LEVEL_KEY'][ $value['acat_id'] ]) ) {
         $p1 = $act_path;
      } else {
         $s  = '';           // Reset $struct
         $p1 = '';
      }
 
// Only if there is a sub level     ========
// Nur wenn SubLevel vorhanden ist  ========
 
      if($GLOBALS['content']['cat_id'] == $value['acat_id']) {
 
         $a1 = $act_path;    // Only for a direct call // Nur bei direktem Aufruf (FirstLevel active)
         $a3 = '';           // active
 
      }
      else {               // If first level isn´t active // Wenn FirstLevel nicht aktiv
         $a1 = $p1;
         $a3 = '';
      }
 
// ==========================
 
      // -- <D01> -------------------------------------------------------------------
      // Preset level depth added
      // Ebenetiefenvorgabe hinzugefuegt
      //      $s = buildNavi_horiz($value['acat_id'], $counter+1);
 
      $parameter[1] = $value['acat_id'];  // start_id
 
//      if (($counter) < $depth) {$s = buildNavi_horiz($value['acat_id'], $counter+1, $depth, 'param_is_array');
      if (($counter) < $max_depth) {$s = buildNavi_horiz1($parameter, $counter+1, 'param_is_array');
      }
      else {$s = '';}
      // -- <D01> -------------------------------------------------------------------
 
      // Set the active link class
      // Aktive Link Classe setzen
      ($GLOBALS['content']['cat_id'] == $value['acat_id']) ? $a3 = $active: $a3 = '';
 
      if($s) {
         $g  = '<!--[if gte IE 7]><!--></a><!--<![endif]-->';
         $g .= $s;
         $g .= LF . str_repeat('   ', $counter);
 
         $class = $counter ? (' class="fly_ul '.$a1.$a3.$first_li.'"') : (' class="drop_ul '.$a1.$first_lev.$a3.$first_li.'"'); // Second level with active category
 
         $close_li = str_repeat('   ', $counter+1);
 
      } else {
         $g  = '</a>';
         $class = ' class="sub_no'.$a1.$a3.$first_li.'"';  // act_path auch im letzten activ link
//         $class = ' class="sub_no'.$a3.'"';
        // -- <P01> -------------------------------------------------------------------
         // Only the first level if there is no sub level
         // Ausschlieszlich das erste Level wenn kein Sublevel vorhanden ist
         if ($counter == 0) {
            $class = ' class="sub_no'.$a1.$first_lev.$first_li.'"';  // Set it, it is active or not // Es ist aktiv oder nicht
         // -- <P01> -------------------------------------------------------------------
         }
         $close_li = '';
      }
 
//    first li in block          =======
//    Erstes li im letzten Block =======
      if( $last && $last == $x ) {
         $enclose = ' class="horiz_enclose"';
      } elseif( $x || ($counter == 0 && $x == 0) ) {
         $enclose = '';
      } else {
         $enclose = ' class="horiz_enclose"';
      }
 
//    IDs for every li  ======= If you need the ID class, please uncomment/comment
//    IDs fuer jedes li ======= Wenn sie die ID Klassen benoetigen, bitte dekommentieren/kommentieren
//      $l  = str_repeat('   ', $counter+1) . '<li'. $class . ' id="cat-id_' . $value['acat_id'] . '">';
      if ($level_id_name)
         $l  = str_repeat('   ', $counter+1) . '<li'. $class . ' id="'.$level_id_name.'_'. $value['acat_id'] . '">';
      else
         $l  = str_repeat('   ', $counter+1) . '<li'. $class . '>';
 
 
      $l .= get_level_ahref($value['acat_id'], $enclose) . html_specialchars($value['acat_name']);
      $l .= $g;
 
 
      $l .=  $close_li . '</li>';
 
      $t[] = $l;
 
      $x++;
 
      $first_li = ''; // Reset first_li
 
   } // END foreach
 
   if($counter) {
      $A = LF . str_repeat('   ', $counter) . '<!--[if lte IE 6]><table><tr><td><![endif]-->';
      $B = LF . str_repeat('   ', $counter) . '<!--[if lte IE 6]></td></tr></table></a><![endif]-->';
   } else {
      $A = '';
      $B = '';
   }
 
 
   $t = implode(LF, $t);
   if($t) {
      $t =   $A . LF . str_repeat('   ', $counter) .   '<ul class="level-'.($counter+1).' '.(($counter)?'':$menu_class).'">' . LF . $t . LF . str_repeat('   ', $counter) . '</ul>'.   $B ;
   }
 
/*
   // -- <E01> -------------------------------------------------------------------
   // EDIT: 07/11/25 KH. (flip-flop) including simple Tags in category headline 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>';
 
   // ========== end copy&paste ========
 
   $t = preg_replace($search, $replace, $t);
 
   // -- <E01> -------------------------------------------------------------------
*/
 
   return $t;
}
?>


CSS zu V1.2:

nav_horiz_drop_down.css

/* ================================================================
This copyright notice must be untouched at all times.
 
The original version of this stylesheet and the associated (x)htmlis
available at http://www.cssplay.co.uk/menus/simple_vertical.html
Copyright (c) 2005-2007 Stu Nicholls. All rights reserved.
This stylesheet and the associated (x)html may be modified in any
way to fit your requirements.
 
08.11.07 KH (flip-flop) Enhanced: Start[ID] {NAV_HORIZ_DD:ID}
http://www.phpwcms.de/forum/viewtopic.php?p=94688#94688
(http://www.phpwcms.de/forum/viewtopic.php?p=89743#89743)
V1.1 05.03.2010 KH: For active path
=================================================================== */
/* Add a margin - for this demo only - and a relative position with a high z-index to make it appear over any element below */
/* margin hinzugefuegt - ausschließlich fuer diese demo - und ein "relative position" mit einem hohen z-index Wert um sicherzustellen dass das Menue ueber jedem nachfolgenden Element aufklappt. */
 
#menu_container {
/*       margin: 0 0 100px 0;  /* 100px only for testing - default = 0 */
   position: relative;
   width: 990px;
   height: 21px;      /* ORG 20px */
   z-index: 1000;
}
/* Get rid of the margin, padding and bullets in the unordered lists */
/* margin und padding auf 0, Aufzählungszeichen der unsortierten Liste unterdruecken */
.hmenu, .hmenu ul {
   padding: 0;
   margin: 0;
   list-style-type: none;
}
/* Set up the link size, color and borders */
/* Einstellen der Groeszen, Farben und Rahmen fuer die Links */
.hmenu a, .hmenu a:visited {
   display: block;
   width: 150px;
   font-size: 11px;
   color: #fff;
   height: 21px;      /* ORG 25px */
   line-height: 20px; /* ORG 24px */
   text-decoration: none;
   text-indent: 5px;
   border: 1px solid #fff;
   border-width: 1px 0 1px 1px;
}
/* Set up the sub level borders */
/* Einstellen der Rahmen fuer die Unterebenen  */
.hmenu li ul li a, .hmenu li ul li a:visited {
   border-width: 0 1px 1px 1px;
}
.hmenu li a.horiz_enclose, .hmenu li a.horiz_enclose:visited {
   border-width: 1px;
}
/* Set up the list items */
/* Einstellen der Listeneinzelheiten */
.hmenu li {
   float: left;
        list-style-type: none;
   background: #7484ad;
}
/* For Non-IE browsers and IE7 */
/* Fuer alle nicht IE + IE7 */
.hmenu li:hover {
   position: relative;
}
/* Make the hovered list color persist */
/* Festlegen der Farbe fuer hover li */
.hmenu li:hover > a {
   background: #D1D5DF; /* ORG #dfd7ca; */
   color: #BF4300;      /* ORG #c00; */
}
 
.hmenu li.act_path:hover > a {
   background:#8FB0FF url(../../img/symbols/klapp_auf.gif) no-repeat 135px center;
   color: #fff;
/*   background:#cccccc url(../../img/article/navi/drop.gif) no-repeat right center;
   */
}
 
.hmenu li li.act_path:hover > a {
   background:#8FB0FF url(../../img/symbols/klapp_zu.gif) no-repeat 135px center;
   color: #fff;
}
 
.hmenu li li.act_path:hover > a {
   background:#8FB0FF url(../../img/symbols/klapp_zu.gif) no-repeat 135px center;
   color: #fff;
}
 
.hmenu li li.sub_no.act_path:hover > a {
   background:red  no-repeat 135px center;
   color: #fff;
}
 
/* Set up the sublevel lists with a position absolute for flyouts and overrun padding. The transparent gif (leer.gif) is for IE to work */
/* Einstellen der Unterebenenlisten mit einer absoluten Positionierung fuer die FlyOuts und dem "Ueberfahren-Abstand"
   Das transparente gif (leer.gif) ist fuer den IE gedacht */
.hmenu li ul {
   display: none;
}
/* For Non-IE and IE7 make the sublevels visible on list hover. This is all it needs */
/* Fuer alle nicht-IE + IE7 wird die Unterebenenliste sichtbar bei einem Ueberfahren (hover) */
.hmenu li:hover > ul {
   display: block;
   position: absolute;
   top: -7px;         /* ORG -11px */
   left: 115px;
   padding: 7px 30px 30px 30px; /* ORG padding: 10px */
   background:transparent url(../../img/article/leer.gif);
   width: 150px;
}
/* Position the first sub level beneath the top level links */
/* Positioniere die erste Unterebene nach dem Topebenenlink */
.hmenu > li:hover > ul {
   left: -30px;
   top: 16px;
}
/* get rid of the table */
/* Tabelle neu einstellen */
.hmenu table {
   position: absolute;
   border-collapse: collapse;
   top: 0;
   left: 0;
   z-index: 1000;
   font-size: 1em;
}
/* For IE5.5 and IE6 give the hovered links a position relative and a change of background and foreground color. This is needed to trigger IE to show the sub levels */
/* Fuer den IE5 und IE6 gebe dem hover-Link eine relative Position und wechsele die Hinter- und Vordergrundfarbe. Das ist notwendig damit der IE angestoszen wird die Unterebenen auszugeben */
* html .hmenu li a:hover {
   position: relative;
   background: #D1D5DF; /* ORG #dfd7ca; */
   color: #c00;
}
 
.hmenu li.drop_ul {
   background: #7484ad url(../../img/symbols/klapp_auf.gif) no-repeat 135px center;
   /* background: #7484ad url(../../img/article/navi/drop.gif) no-repeat right center;
*/
}
/* active path ======================== */
/* KH: Active Path output first level */
/* KH: Ausgabe des aktiven Pfads erste Ebene */
.hmenu li.act_path {
   background:#4161AF url(../../img/symbols/klapp_auf.gif) no-repeat 135px center;
/*   background:#cccccc url(../../img/article/navi/drop.gif) no-repeat right center;
   */
}
/* KH: Active Path output */
/* KH: Ausgabe des aktiven Pfads */
.hmenu li li.act_path,
.hmenu li li li.act_path,
.hmenu li li li li.act_path,
.hmenu li li li li li.act_path {
   background:#4161AF url(../../img/symbols/klapp_zu.gif) no-repeat 137px center;
/*   background:#cccccc url(../../img/article/navi/drop.gif) no-repeat right center;
   */
}
 
/* Set up the pointers for the sub level indication */
/* Einstellen der Symbole/Pfeile für die Unterebenenanzeige */
.hmenu li.fly_ul {
   background: #7484ad url(../../img/symbols/klapp_zu.gif) no-repeat 137px center;
/*   background: #7484ad url(../../img/article/navi/fly.gif) no-repeat right center;
*/
}
/* active link ======================== */
/* For accessibility of the top level menu when tabbing */
/* Fuer die Aktivierung der ersten Ebene, wenn im Menue geblättert wird */
.hmenu li a:active, .hmenu li a:focus {
   background: #6189DF;
   color: #BF4300;      /* ORG #c00; */
}
/* active link in first level */
/* Aktiver Link in der ersten Ebene */
.hmenu li.active {
   background-color: #6F99FF;
   color: #BF4300;      /* ORG #c00; */
}
/* active link behind first level */
/* Aktiver Link nach der ersten Ebene */
.hmenu li li.active,
.hmenu li li li.active,
.hmenu li li li li.active,
.hmenu li li li li li.active {
   background: #6890EF;
   color: #BF4300;      /* ORG #c00; */
}
 
/* This lot is for IE5.5 and IE6 ONLY and is necessary to make the sublevels appear */
/* change the drop down levels from display:none; to visibility:hidden; */
/* Dies ist fuer den IE5.5 und IE6 notwendig um die Unterebenen anzuzeigen */
/* Wechselt die Unterebenen von display:none; nach visibility:hidden; */
 
* html .hmenu li ul {
   visibility: hidden;
   display: block;
   position: absolute;
   top: -11px;
   left: 115px;
   padding: 10px 30px 30px 30px;
   background: transparent url(../../img/article/leer.gif);
}
/* keep the third level+ hidden when you hover on first level link */
.hmenu li a:hover ul ul {
   visibility: hidden;
}
/* keep the fourth level+ hidden when you hover on second level link */
.hmenu li a:hover ul a:hover ul ul {
   visibility: hidden;
}
/* keep the fifth level hidden when you hover on third level link */
.hmenu li a:hover ul a:hover ul a:hover ul ul {
   visibility: hidden;
}
/* keep the sixth level hidden when you hover on fourth level link */
.hmenu li a:hover ul a:hover ul a:hover ul a:hover ul ul {
   visibility: hidden;
}
/* make the second level visible when hover on first level link and position it */
.hmenu li a:hover ul {
   visibility: visible;
   left: -30px;       /*          (IE5 ONLY) */
   top: 10px;         /* ORG 14px (IE5 ONLY) */
   lef\t: -31px;      /*          (IE6 ONLY) */
   to\p: 11px;        /* ORG 15px (IE6 ONLY) */
}
/* make the third level visible when you hover over second level link and position it and all further levels */
.hmenu li a:hover ul a:hover ul {
   visibility: visible;
   top: -11px;        /* ORG -11px (IE6 ONLY) */
   left: 115px;
}
/* make the fourth level visible when you hover over third level link */
.hmenu li a:hover ul a:hover ul a:hover ul {
   visibility: visible;
}
/* make the fifth level visible when you hover over fourth level link */
.hmenu li a:hover ul a:hover ul a:hover ul a:hover ul {
   visibility: visible;
}
/* make the sixth level visible when you hover over fifth level link */
.hmenu li a:hover ul a:hover ul a:hover ul a:hover ul a:hover ul {
   visibility: visible;
}
/* If you can see the pattern in the above IE5.5 and IE6 style then you can add as many sub levels as you like */



PHP V1.2b

Update 22.12.2010 KH:

  • Der Linktext kann in z.B. <span> ... </span> eingefasst werden (wrap link text).
  • Parameter: "WrapIn|WrapOut"


   <ul class="level-2 ">
      <li class="sub_no sub_first" id="cat_14"><a href="index.php?category04_01" class="horiz_enclose"><span>Category04_01</span></a></li>
      <li class="sub_no" id="cat_15"><a href="index.php?category04_02"><span>Category04_02<br>auch Text</span></a></li>
      <li class="sub_no" id="cat_20"><a href="index.php?category04_03"><span>Category04_03</span></a></li>
            ........

Typischer Aufruf:

<div class="hmenu">{NAV_HORIZ_DD1:,0,4,cat,my_class,<span>|</span> }</div>

Dateiname: rt_nav_horiz_drop_down_v12.php

Ort: /template/inc_script/frontend_render/

rt_nav_horiz_drop_down_v12.php

<?php
/**
* **************************************************************************
* V1.2b  22.12.2010 K.heermann http://planmatrix.de
*
* 25.07.07 horizontal drop-down with ID output -> NAVI HORIZONTAL DROP-DOWN
* Oliver Georgi
* http://www.phpwcms.de/forum/viewtopic.php?p=89743#89743
* 08.11.07 KH (flip-flop) Enhanced: Start[ID] {NAV_HORIZ_DD:ID}
* 28.04.08 KH (flip-flop) Enhanced: Level depth {NAV_HORIZ_DD:ID,Depth}
* http://www.phpwcms.de/forum/viewtopic.php?p=94688#94688
* 05.03.10 KH (flip-flop) Enhanced: Menu type, H&P, id for every li
* @string $parameter = "menu type, start_id, max_level_depth, id for ervery li"
*  - Menu type:        H=Home on|off, P=Parent on|off
*  - id for ervery li: class name
* 16.12.10 KH (flip-flop) Enhanced: Every first <li> is marked with the
* class "sub_first"
* 16.12.10 KH (flip-flop) Enhanced: Class in TAG (ul class="Name">)
* - TAG:      {NAV_HORIZ_DD1:Menu type, Start-ID, Level depth, li id_name,class_name}
* - E.g.:     {NAV_HORIZ_DD1:H, 2, 3, id}
*
* 22.12.10 KH (flip-flop) Enhanced: Wrap-link-text in TAG (..><wrapIn>LinkText</WrapOut>">)
* - TAG:      {NAV_HORIZ_DD1:Menu type, Start-ID, Level depth, li id_name,class_name,<em>|</em>}
* - E.g.:     {NAV_HORIZ_DD1:H, 2, 3, cat, my_class,<span>|</span>}
*
* Location: Put it into the file e.g.:
*           /template/inc_script/frontend_render/rt_nav_horiz_drop_down_v11.php
* Switch in conf.inc.php: $phpwcms['allow_ext_render']  = 1;
* **************************************************************************
*/
// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
   die("You Cannot Access This Script Directly, Have a Nice Day."); }
// ----------------------------------------------------------------
 
if( ! ( strpos($content["all"],'{NAV_HORIZ_DD1')==false ) ) {
 
    $content["all"] = str_replace('{NAV_HORIZ_DD1}','{NAV_HORIZ_DD1:,0,100}',$content["all"]);  // For a simple call
    $content["all"] = preg_replace('/\{NAV_HORIZ_DD1:(.*?)\}/e', 'buildNavi_horiz1("$1");', $content["all"]);
}
 
 
 
//function buildNavi_horiz($start=0, $counter=0, $depth=0) {
function buildNavi_horiz1($parameter='', $counter=0, $param='string') {
 
 
    // ====== CUSTOM VAR ==========================================
 
    $menu_class = ' hmenu';  // Menu class name // Menue Klassenname
 
    $first_lev    = ' first-level';
    $act_path    = ' act_path';
    $active     = ' active';        // The active link  // Der aktive Link
   // ====== CUSTOM VAR ENDE ======================================
 
 
    // only for the first call from extern
    // Nur fuer den ersten externen Aufruf
    if($param == 'string') {
 
        $parameter         = explode(',', $parameter);
 
        // first entry a digit or sign?  Only for compatibility to the older nav version
        // Erster Eintrag eine Zahl?  Nur fuer Kompatibilität mit aeltere Navi Version
        if (isset($parameter[0])  AND  (preg_match('/^[0-9]+$/i',$parameter[0])) ) {
 
            array_unshift ( $parameter, '' );  // Fill up array for $menu_type
        }
        $menu_type        = empty($parameter[0]) ? '' : strtoupper(trim($parameter[0]));
        $start_id        = empty($parameter[1]) ? 0  : intval($parameter[1]);
        $max_depth        = empty($parameter[2]) ? 0  : intval($parameter[2]-1);
        $level_id_name    = empty($parameter[3]) ? '' : trim($parameter[3]);
        $menu_class       = empty($parameter[4]) ? $menu_class : ' '.trim($parameter[4]);
        $wrap_link_text    = empty($parameter[5]) ? array(0 => '', 1 => '') : explode('|', trim($parameter[5]), 2);
        if(empty($wrap_link_text[1])) {
           $wrap_link_text[1] = '';
        }
        $parent            = false; // do not show parent link
        $home            = false; // do not show home link
 
 
        switch($menu_type) {
                            // show parent level too - only in first line  [Parent]
            case 'P':        $parent = true;
                            break;
 
                            // Home in the first line  [Home] [Cat01] [Cat02] [Cat03]
            case 'HP':        $parent = true;
            case 'H':        $home     = true;
                            if($start_id == '0' AND $parent) $home = false;
                            break;
        }
 
 
         $parameter        = array( 0 => $menu_type,          1 => $start_id,          2 => $max_depth,
                                 3 => $level_id_name,     4 => $menu_class,         5 => $wrap_link_text
                             );
 
    } else {  // for the inner call (recursive run)
 
        $menu_type        = $parameter[0];
        $start_id        = $parameter[1];
        $max_depth        = $parameter[2]-1;
        $level_id_name    = $parameter[3];
        $menu_class        = $parameter[4];
        $wrap_link_text    = $parameter[5];
        $parent            = false; // do not show parent link
        $home            = false; // do not show home link
 
    }
 
 
    // ----- System var ----------------
    $t = array();
    $x = 0;
    // ---------------------------------
 
   $struct = getStructureChildData($start_id);  // Catch structure
 
 
   if($counter == 0) {
      $last = count($start_id) - 1;
 
      // ======== Only if you want the home link // Nur wenn Home gewuenscht
      if ($home) { // Home in the first line  [Home] [Cat01] [Cat02] [Cat03]
 
          $l  = '   <li '.
                            (($level_id_name) ? 'id="'.$level_id_name.'_0" ' : '').
                            'class="drop home'.$first_lev.$a4.
                            (($GLOBALS['content']['cat_id'] == 0)?$active:'').
                            '">';
          $l .= get_level_ahref($start_id, ' class="home"') . '<span>'. html_specialchars($GLOBALS['content']['struct']['0']['acat_name']);
          $l .= '</span></a></li>';
          $t[] = $l;
      }
 
      // ======== Only if you want the parent link // Nur wenn der Eltern-Link gewuenscht
      if ($parent) { // Parent only in first line  [Parent]
 
          $struct = array();  // clear array  // Array leeren
          $struct[$start_id] = $GLOBALS['content']['struct'][$start_id];
     }
      // ========
 
   } else {
      $last = 0;
   }
 
 
   $first_li = ' sub_first';  // Init first <li> flag
 
   foreach($struct as $value) {
 
 
// ============
// dumpVar($value['acat_id']);
 
// Is it a active path ?      ========
// Ist dies der aktive Pfad ? ========
      if( isset($GLOBALS['LEVEL_KEY'][ $value['acat_id'] ]) ) {
         $p1 = $act_path;
      } else {
         $s  = '';           // Reset $struct
         $p1 = '';
      }
 
// Only if there is a sub level     ========
// Nur wenn SubLevel vorhanden ist  ========
 
      if($GLOBALS['content']['cat_id'] == $value['acat_id']) {
 
         $a1 = $act_path;    // Only for a direct call // Nur bei direktem Aufruf (FirstLevel active)
         $a3 = '';           // active
 
      }
      else {               // If first level isn´t active // Wenn FirstLevel nicht aktiv
         $a1 = $p1;
         $a3 = '';
      }
 
// ==========================
 
      // -- <D01> -------------------------------------------------------------------
      // Preset level depth added
      // Ebenetiefenvorgabe hinzugefuegt
      //      $s = buildNavi_horiz($value['acat_id'], $counter+1);
 
      $parameter[1] = $value['acat_id'];  // start_id
 
//      if (($counter) < $depth) {$s = buildNavi_horiz($value['acat_id'], $counter+1, $depth, 'param_is_array');
      if (($counter) < $max_depth) {$s = buildNavi_horiz1($parameter, $counter+1, 'param_is_array');
      }
      else {$s = '';}
      // -- <D01> -------------------------------------------------------------------
 
      // Set the active link class
      // Aktive Link Classe setzen
      ($GLOBALS['content']['cat_id'] == $value['acat_id']) ? $a3 = $active: $a3 = '';
 
      if($s) {
         $g  = '<!--[if gte IE 7]><!--></a><!--<![endif]-->';
         $g .= $s;
         $g .= LF . str_repeat('   ', $counter);
 
         $class = $counter ? (' class="fly_ul '.$a1.$a3.$first_li.'"') : (' class="drop_ul '.$a1.$first_lev.$a3.$first_li.'"'); // Second level with active category
 
         $close_li = str_repeat('   ', $counter+1);
 
      } else {
         $g  = '</a>';
         $class = ' class="sub_no'.$a1.$a3.$first_li.'"';  // act_path auch im letzten activ link
//         $class = ' class="sub_no'.$a3.'"';
        // -- <P01> -------------------------------------------------------------------
         // Only the first level if there is no sub level
         // Ausschlieszlich das erste Level wenn kein Sublevel vorhanden ist
         if ($counter == 0) {
            $class = ' class="sub_no'.$a1.$first_lev.$first_li.'"';  // Set it, it is active or not // Es ist aktiv oder nicht
         // -- <P01> -------------------------------------------------------------------
         }
         $close_li = '';
      }
 
//    first li in block          =======
//    Erstes li im letzten Block =======
      if( $last && $last == $x ) {
         $enclose = ' class="horiz_enclose"';
      } elseif( $x || ($counter == 0 && $x == 0) ) {
         $enclose = '';
      } else {
         $enclose = ' class="horiz_enclose"';
      }
 
//    IDs for every li  ======= If you need the ID class, please uncomment/comment
//    IDs fuer jedes li ======= Wenn sie die ID Klassen benoetigen, bitte dekommentieren/kommentieren
//      $l  = str_repeat('   ', $counter+1) . '<li'. $class . ' id="cat-id_' . $value['acat_id'] . '">';
      if ($level_id_name)
         $l  = str_repeat('   ', $counter+1) . '<li'. $class . ' id="'.$level_id_name.'_'. $value['acat_id'] . '">';
      else
         $l  = str_repeat('   ', $counter+1) . '<li'. $class . '>';
 
 
      $l .= get_level_ahref($value['acat_id'], $enclose) . $wrap_link_text[0]. html_specialchars($value['acat_name']).$wrap_link_text[1];
      $l .= $g;
 
 
      $l .=  $close_li . '</li>';
 
      $t[] = $l;
 
      $x++;
 
      $first_li = ''; // Reset first_li
 
   } // END foreach
 
   if($counter) {
      $A = LF . str_repeat('   ', $counter) . '<!--[if lte IE 6]><table><tr><td><![endif]-->';
      $B = LF . str_repeat('   ', $counter) . '<!--[if lte IE 6]></td></tr></table></a><![endif]-->';
   } else {
      $A = '';
      $B = '';
   }
 
 
   $t = implode(LF, $t);
   if($t) {
      $t =   $A . LF . str_repeat('   ', $counter) .   '<ul class="level-'.($counter+1).' '.(($counter)?'':$menu_class).'">' . LF . $t . LF . str_repeat('   ', $counter) . '</ul>'.   $B ;
   }
 
/*
   // -- <E01> -------------------------------------------------------------------
   // EDIT: 07/11/25 KH. (flip-flop) including simple Tags in category headline 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>';
   $search[22]      = '/\[br\]/is';                    $replace[22]   = '<br>';
 
   // ========== end copy&paste ========
 
 
 
   $t = preg_replace($search, $replace, $t);
/*
   // -- <E01> -------------------------------------------------------------------
*/
 
   return $t;
}
?>


PHP V1.2c

Update 18.11.2011 KH:

  • Der title TAG zu jedem Link kann ausgegeben werden z.B. <a href="Link..." ...title="Kategoriename">.
  • Parameter im Script in CUSTOM VAR: "$title = true/false"


   <ul class="level-2 ">
      <li class="sub_no sub_first" id="cat_14"><a href="index.php?category04_01" class="horiz_enclose title="Category04_01"><span>Category04_01</span></a></li>
      <li class="sub_no" id="cat_15"><a href="index.php?category04_02" title="Category04_02 auch Text"><span>Category04_02<br> auch Text</span></a></li>
      <li class="sub_no" id="cat_20"><a href="index.php?category04_03" title="Category04_03><span>Category04_03</span></a></li>
            ........

Typischer Aufruf:

<div class="hmenu">{NAV_HORIZ_DD1:,0,4,cat,my_class,<span>|</span> }</div>

Dateiname: rt_nav_horiz_drop_down_v12.php

Ort: /template/inc_script/frontend_render/

rt_nav_horiz_drop_down_v12.php

<?php
/**
* **************************************************************************
* V1.2c  18.11.2011 K.heermann http://planmatrix.de
*
* 25.07.07 horizontal drop-down with ID output -> NAVI HORIZONTAL DROP-DOWN
* Oliver Georgi
* http://www.phpwcms.de/forum/viewtopic.php?p=89743#89743
* 08.11.07 KH (flip-flop) Enhanced: Start[ID] {NAV_HORIZ_DD:ID}
* 28.04.08 KH (flip-flop) Enhanced: Level depth {NAV_HORIZ_DD:ID,Depth}
* http://www.phpwcms.de/forum/viewtopic.php?p=94688#94688
* 05.03.10 KH (flip-flop) Enhanced: Menu type, H&P, id for every li
* @string $parameter = "menu type, start_id, max_level_depth, id for ervery li"
*  - Menu type:        H=Home on|off, P=Parent on|off
*  - id for ervery li: class name
* 16.12.10 KH (flip-flop) Enhanced: Every first <li> is marked with the
* class "sub_first"
* 16.12.10 KH (flip-flop) Enhanced: Class in TAG (ul class="Name">)
* - TAG:      {NAV_HORIZ_DD1:Menu type, Start-ID, Level depth, li id_name,class_name}
* - E.g.:     {NAV_HORIZ_DD1:H, 2, 3, id}
*
* 22.12.10 KH (flip-flop) Enhanced: Wrap-link-text in TAG (..><wrapIn>LinkText</WrapOut>">)
* - TAG:      {NAV_HORIZ_DD1:Menu type, Start-ID, Level depth, li id_name,class_name,<em>|</em>}
* - E.g.:     {NAV_HORIZ_DD1:H, 2, 3, cat, my_class,<span>|</span>}
*
* 18.11.11 KH (flip-flop) Enhanced: title output in link yes/no
*
* Location: Put it into the file e.g.:
*           /template/inc_script/frontend_render/rt_nav_horiz_drop_down_v11.php
* Switch in conf.inc.php: $phpwcms['allow_ext_render']  = 1;
* **************************************************************************
*/
// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
   die("You Cannot Access This Script Directly, Have a Nice Day."); }
// ----------------------------------------------------------------
 
if( ! ( strpos($content["all"],'{NAV_HORIZ_DD1')==false ) ) {
 
    $content["all"] = str_replace('{NAV_HORIZ_DD1}','{NAV_HORIZ_DD1:,0,100}',$content["all"]);  // For a simple call
    $content["all"] = preg_replace('/\{NAV_HORIZ_DD1:(.*?)\}/e', 'buildNavi_horiz1("$1");', $content["all"]);
}
 
 
 
//function buildNavi_horiz($start=0, $counter=0, $depth=0) {
function buildNavi_horiz1($parameter='', $counter=0, $param='string') {
 
 
    // ====== CUSTOM VAR ==========================================
 
    $menu_class = ' hmenu';     // Menu class name // Menue Klassenname
 
    $first_lev  = ' first';
    $act_path   = ' act_path';
    $active     = ' active';    // The active link  // Der aktive Link
    $title      = false;        // Title ausgeben ja/nein
   // ====== CUSTOM VAR ENDE ======================================
 
 
    // only for the first call from extern
    // Nur fuer den ersten externen Aufruf
    if($param == 'string') {
 
        $parameter         = explode(',', $parameter);
 
        // first entry a digit or sign?  Only for compatibility to the older nav version
        // Erster Eintrag eine Zahl?  Nur fuer Kompatibilität mit aeltere Navi Version
        if (isset($parameter[0])  AND  (preg_match('/^[0-9]+$/i',$parameter[0])) ) {
 
            array_unshift ( $parameter, '' );  // Fill up array for $menu_type
        }
        $menu_type        = empty($parameter[0]) ? '' : strtoupper(trim($parameter[0]));
        $start_id         = empty($parameter[1]) ? 0  : intval($parameter[1]);
        $max_depth        = empty($parameter[2]) ? 0  : intval($parameter[2]-1);
        $level_id_name    = empty($parameter[3]) ? '' : trim($parameter[3]);
        $menu_class       = empty($parameter[4]) ? $menu_class : ' '.trim($parameter[4]);
        $wrap_link_text   = empty($parameter[5]) ? array(0 => '', 1 => '') : explode('|', trim($parameter[5]), 2);
        if(empty($wrap_link_text[1])) {
           $wrap_link_text[1] = '';
        }
        $parent          = false; // do not show parent link
        $home            = false; // do not show home link
 
 
        switch($menu_type) {
                            // show parent level too - only in first line  [Parent]
            case 'P':        $parent = true;
                            break;
 
                            // Home in the first line  [Home] [Cat01] [Cat02] [Cat03]
            case 'HP':       $parent = true;
            case 'H':        $home     = true;
                            if($start_id == '0' AND $parent) $home = false;
                            break;
        }
 
 
         $parameter        = array( 0 => $menu_type,          1 => $start_id,          2 => $max_depth,
                                 3 => $level_id_name,     4 => $menu_class,         5 => $wrap_link_text
                             );
 
    } else {  // for the inner call (recursive run)
 
        $menu_type       = $parameter[0];
        $start_id        = $parameter[1];
        $max_depth       = $parameter[2]-1;
        $level_id_name   = $parameter[3];
        $menu_class      = $parameter[4];
        $wrap_link_text  = $parameter[5];
        $parent          = false; // do not show parent link
        $home            = false; // do not show home link
 
    }
 
 
    // ----- System var ----------------
    $t = array();
    $x = 0;
    // ---------------------------------
 
   $struct = getStructureChildData($start_id);  // Catch structure
 
 
   if($counter == 0) {
      $last = count($start_id) - 1;
 
      // ======== Only if you want the home link // Nur wenn Home gewuenscht
      if ($home) { // Home in the first line  [Home] [Cat01] [Cat02] [Cat03]
 
          $l  = '   <li '.
                            (($level_id_name) ? 'id="'.$level_id_name.'_0" ' : '').
                            'class="drop home'.$first_lev.$a4.
                            (($GLOBALS['content']['cat_id'] == 0)?$active:'').
                            '">';
          if (!$title)
             $l .= get_level_ahref($start_id, ' class="home"') . '<span>'. html_specialchars($GLOBALS['content']['struct']['0']['acat_name']);
          else
             $l .= get_level_ahref($start_id, ' class="home" title="'.html_specialchars($GLOBALS['content']['struct']['0']['acat_name']).'"') . '<span>'. html_specialchars($GLOBALS['content']['struct']['0']['acat_name']);
 
          $l .= '</span></a></li>';
          $t[] = $l;
      }
 
      // ======== Only if you want the parent link // Nur wenn der Eltern-Link gewuenscht
      if ($parent) { // Parent only in first line  [Parent]
 
          $struct = array();  // clear array  // Array leeren
          $struct[$start_id] = $GLOBALS['content']['struct'][$start_id];
     }
      // ========
 
   } else {
      $last = 0;
   }
 
 
   $first_li = ' sub_first';  // Init first <li> flag
 
   foreach($struct as $value) {
 
 
// ============
// dumpVar($value['acat_id']);
 
// Is it a active path ?      ========
// Ist dies der aktive Pfad ? ========
      if( isset($GLOBALS['LEVEL_KEY'][ $value['acat_id'] ]) ) {
         $p1 = $act_path;
      } else {
         $s  = '';           // Reset $struct
         $p1 = '';
      }
 
// Only if there is a sub level     ========
// Nur wenn SubLevel vorhanden ist  ========
 
      if($GLOBALS['content']['cat_id'] == $value['acat_id']) {
 
         $a1 = $act_path;    // Only for a direct call // Nur bei direktem Aufruf (FirstLevel active)
         $a3 = '';           // active
 
      }
      else {                // If first level isn´t active // Wenn FirstLevel nicht aktiv
         $a1 = $p1;
         $a3 = '';
      }
 
// ==========================
 
      // -- <D01> -------------------------------------------------------------------
      // Preset level depth added
      // Ebenetiefenvorgabe hinzugefuegt
      //      $s = buildNavi_horiz($value['acat_id'], $counter+1);
 
      $parameter[1] = $value['acat_id'];  // start_id
 
//      if (($counter) < $depth) {$s = buildNavi_horiz($value['acat_id'], $counter+1, $depth, 'param_is_array');
      if (($counter) < $max_depth) {$s = buildNavi_horiz1($parameter, $counter+1, 'param_is_array');
      }
      else {$s = '';}
      // -- <D01> -------------------------------------------------------------------
 
      // Set the active link class
      // Aktive Link Classe setzen
      ($GLOBALS['content']['cat_id'] == $value['acat_id']) ? $a3 = $active: $a3 = '';
 
      if($s) {
         $g  = '<!--[if gte IE 7]><!--></a><!--<![endif]-->';
         $g .= $s;
         $g .= LF . str_repeat('   ', $counter);
 
         $class = $counter ? (' class="fly_ul '.$a1.$a3.$first_li.'"') : (' class="drop_ul '.$a1.$first_lev.$a3.$first_li.'"'); // Second level with active category
 
         $close_li = str_repeat('   ', $counter+1);
 
      } else {
         $g  = '</a>';
         $class = ' class="sub_no'.$a1.$a3.$first_li.'"';  // act_path auch im letzten activ link
//         $class = ' class="sub_no'.$a3.'"';
        // -- <P01> -------------------------------------------------------------------
         // Only the first level if there is no sub level
         // Ausschlieszlich das erste Level wenn kein Sublevel vorhanden ist
         if ($counter == 0) {
            $class = ' class="sub_no'.$a1.$first_lev.$first_li.'"';  // Set it, it is active or not // Es ist aktiv oder nicht
         // -- <P01> -------------------------------------------------------------------
         }
         $close_li = '';
      }
 
//    first li in block          =======
//    Erstes li im letzten Block =======
      if( $last && $last == $x ) {
         $enclose = ' class="horiz_enclose"';
      } elseif( $x || ($counter == 0 && $x == 0) ) {
         $enclose = '';
      } else {
         $enclose = ' class="horiz_enclose"';
      }
 
//    IDs for every li  ======= If you need the ID class, please uncomment/comment
//    IDs fuer jedes li ======= Wenn sie die ID Klassen benoetigen, bitte dekommentieren/kommentieren
//      $l  = str_repeat('   ', $counter+1) . '<li'. $class . ' id="cat-id_' . $value['acat_id'] . '">';
      if ($level_id_name)
         $l  = str_repeat('   ', $counter+1) . '<li'. $class . ' id="'.$level_id_name.'_'. $value['acat_id'] . '">';
      else
         $l  = str_repeat('   ', $counter+1) . '<li'. $class . '>';
 
      if (!$title)
          $l .= get_level_ahref($value['acat_id'], $enclose) . $wrap_link_text[0]. html_specialchars($value['acat_name']).$wrap_link_text[1];
      else
          $l .= get_level_ahref($value['acat_id'], $enclose.' title="'.html_specialchars($value['acat_name']).'"') . $wrap_link_text[0]. html_specialchars($value['acat_name']).$wrap_link_text[1];
 
      $l .= $g;
 
 
      $l .=  $close_li . '</li>';
 
      $t[] = $l;
 
      $x++;
 
      $first_li = ''; // Reset first_li
 
   } // END foreach
 
   if($counter) {
      $A = LF . str_repeat('   ', $counter) . '<!--[if lte IE 6]><table><tr><td><![endif]-->';
      $B = LF . str_repeat('   ', $counter) . '<!--[if lte IE 6]></td></tr></table></a><![endif]-->';
   } else {
      $A = '';
      $B = '';
   }
 
 
   $t = implode(LF, $t);
   if($t) {
      $t =   $A . LF . str_repeat('   ', $counter) .   '<ul class="level-'.($counter+1).' '.(($counter)?'':$menu_class).'">' . LF . $t . LF . str_repeat('   ', $counter) . '</ul>'.   $B ;
   }
 
/*
   // -- <E01> -------------------------------------------------------------------
   // EDIT: 07/11/25 KH. (flip-flop) including simple Tags in category headline 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 ===========
*/
 
   if ($title) {  // Only if title is set
 
      $search[18]      = '/title="(.*?)\[i\](.*?)\[\/i\](.*?)"/is';         $replace[18]   = 'title="$1$2$3"';
      $search[19]      = '/title="(.*?)\[u\](.*?)\[\/u\](.*?)"/is';         $replace[19]   = 'title="$1$2$3"';
      $search[20]      = '/title="(.*?)\[s\](.*?)\[\/s\](.*?)"/is';         $replace[20]   = 'title="$1$2$3"';
      $search[21]      = '/title="(.*?)\[b\](.*?)\[\/b\](.*?)"/is';         $replace[21]   = 'title="$1$2$3"';
      $search[22]      = '/title="(.*?)\[br\](.*?)"/is';                    $replace[22]   = 'title="$1$2"';
 
      $t = preg_replace($search, $replace, $t);
   }
 
 
   // 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>';
   $search[22]      = '/\[br\]/is';                    $replace[22]   = '<br>';
 
   // ========== end copy&paste ========
 
 
   $t = preg_replace($search, $replace, $t);
/*
   // -- <E01> -------------------------------------------------------------------
*/
 
   return $t;
}
?>


deutsch/navigationen/dropdown_flyout/nav_horiz_dd/erweitert.txt · Last modified: 2018/06/03 18:09 (external edit)
www.planmatrix.de www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0