NAV_VERT_FO:ID,Ebenentiefe

Vertikale Navigation mit Fly-out Mechanismus. Es wird kein JS verwendet!

Eine modifizierte Navigation von O.G.s {NAVI}. (Sehr beeindruckend). Ich würde diese Navigation der NAV_LIST_UL:HCSS immer vorziehen.
Hier das Original von Stu Nicholls: A flyout menu with FOUR sub levels, overlap and overrunNutzungsbedingungen beachten :!:

{NAV_VERT_FO:ID,Ebenentiefe} (NAVi VERTikal Fly Out) V1.0 08.05.08


Docu: –
Forum: http://forum.phpwcms.org/viewtopic.php?p=103442#p103442

Autor: K.Heermann (flip-flop) http://planmatrix.de (26.04.10)
CMS-Version: >= V1.2.8
Version: V1.0 08.05.08

Bedingung:/config/phpwcms/conf.inc.php

  • $phpwcms['allow_ext_render'] = 1;


Möglichkeiten:

  • Fünf Ebenenen tief
  • Überlappen und Überfahr(rahm)en !!!
  • Start-ID im RT
  • Max Leveltiefe im RT (seit 28.04.08)
  • Aktiver Pfad wird für die erste Ebene gekennzeichnet
  • Jedes li hat eine eigene Klasse (optional)
  • Einfache html Tags in der Kategorieüberschrift wie [i] [b] [u] [s]
  • Menügenerator verwendbar



Installation:

  1. Kopieren der beiden Skripte in die jeweils angegebenen Dateien (müssen angelegt werden)
    1. /template/inc_script/frontend_render/rt_nav_vert_fly_out.php
    2. /template/inc_css/nav_vert_fly_out.css
  2. Platzieren des Tags an die Stelle in der Vorlage, an der das Menü erscheinen soll
    • Z.B.: <div id=“menu_container”>{NAV_VERT_FO:0,4}</div>
  3. Einbinden der CSS-Datei in die Vorlage
    • ADMIN → Vorlage → CSS-Datei: [nav_vert_fly_out.css] auswählen (Mehrfachauswahl mit <Strg> linke Maustaste)
  4. Den Tag einstellen (Anfangs-ID und darzustellende Ebenentiefe)
    • Z.B. {NAV_VERT_FO:2,5} (Beginnend in der Ebene mit der ID 2, Darstellung von max. 5 Ebenen in der Tiefe)
  5. CSS-Datei anpassen


TAG

{NAV_VERT_FO:ID,Ebenentiefe} → z.B. Menü beginnt ab Level 0 (Home) und ist tiefenbegrenzt auf zwei Level.

<div id="menu_container">
  <div class="vert_menu">{NAV_VERT_FO:0,2}</div>
</div>


Gegebene Struktur in dem Beispiel:

- root         (index.php  ID=0)
--- Home
--- Ebene01
--- Ebene02
--- Ebene03
--- Ebene04
--- Ebene05
--- Ebene06
  • Es wird im Artikel von root nach home weitergeleitet (permanent 301).
    • Weiterleitung [index.php?home]


PHP

Dateiname: rt_nav_vert_fly_out.php

Ort: /template/inc_script/frontend_render/

rt_nav_vert_fly_out.php

<?php
// **************************************************************************
// 08.11.07 vertical fly-out with ID output -> NAVI VERTICAL FLY-OUT
// Oliver Georgi
// Made for Stu Nicholls http://www.cssplay.co.uk/menus/flyout_4level.html
//
// http://www.phpwcms.de/forum/viewtopic.php?p=89743#89743
// 08.11.07 KH (flip-flop) Enhanced: Start[ID] {NAV_VERT_FO:ID}
// 08.05.08 KH (flip-flop) Enhanced: Level depth {NAV_VERT_FO:ID,Depth}
// 23.05.08 KH (flip-flop) Changed: Inserted new css classes for
//                         css generator compatibility
// TAG [horizontal]: http://forum.phpwcms.org/viewtopic.php?f=1&t=16080
// TAG [vertical]: http://forum.phpwcms.org/viewtopic.php?f=10&t=17233
//
// TAG:      {NAV_VERT_FO:ID,Depth}
// Location: Put it into the file e.g.:
//           /template/inc_script/frontend_render/rt_nav_vert_fly_out.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_VERT_FO')==false ) ) {
   $content["all"] = str_replace('{NAV_VERT_FO}','{NAV_VERT_FO:0,100}',$content["all"]);
  $content["all"] = preg_replace('/\{NAV_VERT_FO:(.*?)\}/i','{NAV_VERT_FO:$1,100}', $content["all"]);
   $content["all"] = preg_replace('/\{NAV_VERT_FO:(.*?),(.*?)\}/e','buildNavi_vert("$1","0","$2"-1);', $content["all"]);
}
// $content['all'] = str_replace('{NAVI}', buildNavi(), $content['all']);
 
function buildNavi_vert($start=0, $counter=0, $depth=0) {
 
   $t = array();
 
   $struct = getStructureChildData($start);  // Catch structure
 
   if($counter == 0) {
      $last = count($struct) - 1;
   } else {
      $last = 0;
   }
 
   $x = 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);
      if (($counter) < $depth) {$s = buildNavi_vert($value['acat_id'], $counter+1, $depth);
      }
      else {$s = '';}
      // -- <D01> -------------------------------------------------------------------
      if($s) {
         $g  = '<!--[if gte IE 7]><!--></a><!--<![endif]-->';
         $g .= $s;
         $g .= LF . str_repeat('   ', $counter);
 
      // -- <C01> -------------------------------------------------------------------
//         $class = $counter ? (' class="fly_ul '.$a1.'"') : (' class="sub_ul '.$a1.'"'); // Second level with activ category
//         $class = $counter ? (' class="fly_ul"') : (' class="sub_ul '.$a1.'"'); // KH:23.05.08 changed
         $class = $counter ? (' class="sub fly_ul"') : (' class="sub sub_ul'.$a1.'"');
 
         $close_li = str_repeat('   ', $counter+1);
 
      } else {
         $g  = '</a>';
         $class = ' class="sub_no"';  // If you don´t use the sub_no please change to: $class = '';
        // -- <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.'"';  // 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="vert_enclose"';
      } elseif( $x || ($counter == 0 && $x == 0) ) {
         $enclose = '';
      } else {
         $enclose = ' class="vert_enclose"';
      }
 
//    IDs for every li  ======= If you need the ID class, please uncomment/comment
//    IDs fuer jedes li ======= Wenn sie die ID Klassen benötigen, bitte dekommentieren/kommentieren
//      $l  = str_repeat('   ', $counter+1) . '<li'. $class . ' id="cat-id_' . $value['acat_id'] . '">';
      $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>' . 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>';
 
   // added simple [br] -> <br />
   $search[25]      = '/\[br\]/i';                           $replace[25]   = '<br />';
   // ========== end copy&paste ========
 
   $t = preg_replace($search, $replace, $t);
 
   // -- <E01> -------------------------------------------------------------------
*/
 
   return $t;
}
?>


NAV_VERT_FO für PHP 7.x

rt_nav_vert_fly_out.php

<?php
 
//error_reporting(E_ALL); ini_set('display_errors', 1);
 
// **************************************************************************
// 08.11.07 vertical fly-out with ID output -> NAVI VERTICAL FLY-OUT
// Oliver Georgi
// http://www.phpwcms.de/forum/viewtopic.php?p=89743#89743
// 08.11.07 KH (flip-flop) Enhanced: Start[ID] {NAV_VERT_FO:ID}
// 08.05.08 KH (flip-flop) Enhanced: Level depth {NAV_VERT_FO:ID,Depth}
// TAG [horizontal]: http://www.phpwcms.de/forum/viewtopic.php?p=89743#89743
// TAG [vertical]: http://forum.phpwcms.org/viewtopic.php?p=103442#p103442
//
// TAG:      {NAV_VERT_FO:ID,Depth}
// Location: Put it into the file e.g.:
//           /template/inc_script/frontend_render/rt_nav_vert_fly_out.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_VERT_FO') == false)) {
    $content["all"] = str_replace('{NAV_VERT_FO}', '{NAV_VERT_FO:0,100}', $content["all"]);
    $content["all"] = preg_replace('/\{NAV_VERT_FO:([0-9]+?)\}/', '{NAV_VERT_FO:$1,100}', $content["all"]);
    $content["all"] = preg_replace_callback('/\{NAV_VERT_FO:(.*?),(.*?)\}/', 'callback_buildNavi_vert', $content["all"]);
}
// $content['all'] = str_replace('{NAVI}', buildNavi(), $content['all']);
 
function callback_buildNavi_vert($match) {
    return buildNavi_vert($match[1], 0, $match[2]-1);
}
 
function buildNavi_vert($start = 0, $counter = 0, $depth = 0) {
 
    $start = intval($start);
    $depth = intval($depth);
 
    $t = array();
    $struct = getStructureChildData($start);  // Catch structure
    $last = $counter ? 0 : count($struct) - 1;
    $x = 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);
        if (($counter) < $depth) {
            $s = buildNavi_vert($value['acat_id'], $counter + 1, $depth);
        } else {
            $s = '';
        }
        // -- <D01> -------------------------------------------------------------------
        if ($s) {
            $g = '<!--[if IE 7]><!--></a><!--<![endif]-->';
            $g .= $s;
            $g .= LF . str_repeat('   ', $counter);
 
            //$class = $counter ? (' class="fly_ul '.$a1.'"') : (' class="sub_ul '.$a1.'"'); // Second level with activ category
            $class = $counter ? (' class="fly_ul"') : (' class="sub_ul ' . $a1 . '"');
 
            $close_li = str_repeat('   ', $counter + 1);
 
        } else {
            $g = '</a>';
            $class = ' class="sub_no"';  // If you don´t use the sub_no please change to: $class = '';
            // -- <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 . '"';  // 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="vert_enclose"';
        }
        elseif ($x || ($counter == 0 && $x == 0)) {
            $enclose = '';
        }
        else {
            $enclose = ' class="vert_enclose"';
        }
 
        //    IDs for every li  ======= If you need the ID class, please uncomment/comment
        //    IDs fuer jedes li ======= Wenn sie die ID Klassen benötigen, bitte dekommentieren/kommentieren
        //$l  = str_repeat('   ', $counter+1) . '<li'. $class . ' id="cat-id_' . $value['acat_id'] . '">';
        $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>' . 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>';
 
       // added simple [br] -> <br />
       $search[25]      = '/\[br\]/i';                           $replace[25]   = '<br />';
       // ========== end copy&paste ========
 
       $t = preg_replace($search, $replace, $t);
 
       // -- <E01> -------------------------------------------------------------------
    */
 
    return $t;
}
?>


Images

Dateinamen: sub.gif, shade.gif, transparent.gif

Ort: /img/article/navi/

navi_img.zip (1.17 KiB, 115 downloads)

CSS

Dateiname: nav_vert_fly_out.css

Ort: /template/inc_css/

/nav_vert_fly_out.css

/* ================================================================
This copyright notice must be untouched at all times.
 
The original version of this stylesheet and the associated (x)html
is available at http://www.cssplay.co.uk/menus/flyout_4level.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_VERT_FO:ID}
08.05.08 KH (flip-flop) Enhanced: Level depth {NAV_VERT_FO:ID,Depth}
Tag [horizontal]: http://www.phpwcms.de/forum/viewtopic.php?p=89743#89743
Tag [vertical]: http://forum.phpwcms.org/viewtopic.php?p=103442#p103442
=================================================================== */
.vert_menu {
height:150px;
font-size:90%;
margin:0px 0 50px 0px; /* this page only */
}
 
/* remove all the bullets, borders and padding from the default list styling */
.vert_menu ul {
position:relative;
z-index:500;
padding:0;
margin:0;
list-style-type:none;
width:200px; /* Kh 150px; */
}
/* style the list items */
.vert_menu li {
background:#d4d8bd url(../../img/article/navi/shade.gif);
height:26px;
list-style-type:none;
/* for IE7 */
float:left;
}
 
 
.vert_menu li.sub_ul, .vert_menu li.fly_ul {background:#d4d8bd url(../../img/article/navi/sub.gif) no-repeat right center;}

.vert_menu li.act_path {background:#cccccc url(../../img/article/navi/sub.gif) no-repeat right center;}

/* get rid of the table */
.vert_menu table {position:absolute; border-collapse:collapse; top:0; left:0; z-index:100; font-size:1em;}
 
/* style the links */
.vert_menu a, .vert_menu a:visited {
display:block;
text-decoration:none;
height:25px;
line-height:25px;
width:199px; /* KH 149px; */
color:#000;
text-indent:5px;
border:1px solid #fff;
border-width:0 1px 1px 1px;
}
/* hack for IE5.5 */
* html .vert_menu a, * html .vert_menu a:visited {width:200px; w\idth:199px;} /* KH {width:150px; w\idth:149px;} */
/* style the link hover */
* html .vert_menu a:hover {color:#efa; background:#aa7; position:relative;}

.vert_menu li:hover {position:relative;}
 
/* For accessibility of the top level menu when tabbing */
.vert_menu a:active, .vert_menu a:focus {color:#efa; background:#aa7;}

/* retain the hover colors for each sublevel IE7 and Firefox etc */
.vert_menu li:hover > a {color:#efa; background:#aa7;}

/* hide the sub levels and give them a positon absolute so that they take up no room */
.vert_menu li ul {
visibility:hidden;
position:absolute;
top:-30px;
/* set up the overlap (minus the overrun) */
left: 150px; /* KH 100px; */
/* set up the overrun area */
padding:30px;
/* this is for IE to make it interpret the overrrun padding */
background:transparent url(../../img/article/navi/transparent.gif);
}
 
/* for browsers that understand this is all you need for the flyouts */
.vert_menu li:hover > ul {visibility:visible;}
 
 
/* for IE5.5 and IE6 you need to style each level hover */
 
/* keep the third level+ hidden when you hover on first level link */
.vert_menu ul a:hover ul ul{
visibility:hidden;
}
/* keep the fourth level+ hidden when you hover on second level link */
.vert_menu ul a:hover ul a:hover ul ul{
visibility:hidden;
}
/* keep the fifth level hidden when you hover on third level link */
.vert_menu ul a:hover ul a:hover ul a:hover ul ul{
visibility:hidden;
}
 
/* make the second level visible when hover on first level link */
.vert_menu ul a:hover ul {
visibility:visible;
}
/* make the third level visible when you hover over second level link */
.vert_menu ul a:hover ul a:hover ul{
visibility:visible;
}
/* make the fourth level visible when you hover over third level link */
.vert_menu ul a:hover ul a:hover ul a:hover ul {
visibility:visible;
}
/* make the fifth level visible when you hover over fourth level link */
.vert_menu ul a:hover ul a:hover ul a:hover ul a:hover ul {
visibility:visible;
}


Menügenerator

Menügenerator (Innerhalb von 10 Minuten kann nun eine CSS-Datei generiert werden).

Aufruf mit generierter CSS z.B.: <div class="menu">{NAV_VERT_FO:0,10}</div>

Soll der aktive Pfad auch kenntlich gemacht werden, kann in die CSS-Datei folgendes eingesetzt werden:

.menu li.act_path {background:#cccccc url(../../img/article/navi/sub.gif) no-repeat right center;}
deutsch/navigationen/dropdown_flyout/nav_vert_fo.txt · Last modified: 2019/12/25 16:56 by Uwe Tholey
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