NAVIGATION
Ein kleines Programm mit dem eine´Kunden- ul/li basierende Navigation erstellt werden kann.
Forum: http://forum.phpwcms.org/viewtopic.php?p=86440#p86440
Autor: Oliver Georgi 2007/05/13
I denke es kanne hilfreich sein für jeden der mit Strukturnavigationen arbeitet. Das Konzept dahinter ist sehr universell.
[Wichtig: Alle “Nummmern” sind Strukturebenen-IDs]
Erstelle eine neue Datei navi_left_right.php in template/inc_script/frontend_render und trage den folgenden Code ein:
<?php // ---------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ---------------------------------------------------------------- // Simple "How To Build Custom Menu" // Forum: http://forum.phpwcms.org/viewtopic.php?p=86440#p86440 // Autor: Oliver Georgi 2007/05/13 // ---------------------------------------------------------------- // Top Navigation $_mainNavi = array(0, 1, 2, 3); // 0 = root, while all others are selected structure level IDs // Left Navigation $_leftNavi = array(4, 5, 6, 7, 8); // left navi IDs $_mainNaviAll = array(); $_leftNaviAll = array(); foreach($_mainNavi as $value) { $_mainNaviAll[$value] = '<li'; if((isset($LEVEL_ID[1]) && $LEVEL_ID[1] == $value) || (!isset($LEVEL_ID[1]) && $value==0)) { $_mainNaviAll[$value] .= ' class="active"'; } $_mainNaviAll[$value] .= '><a href="index.php?'; $_mainNaviAll[$value] .= empty($content['struct'][$value]['acat_alias']) ? 'id='.$value : $content['struct'][$value]['acat_alias']; $_mainNaviAll[$value] .= '">'.html_specialchars($content['struct'][$value]['acat_name']).'</a></li>'; } // @string $parameter = "menu_type, start_id, max_level_depth, class_path, class_active, // ul_id_name, wrap_ul_div(0 = off, 1 = <div>, 2 = <div id="">, 3 = <div class="navLevel-0">), // wrap_link_text(<em>|</em>)" foreach($_leftNavi as $value) { $_leftNaviAll[$value] = '<ul>'.LF; $_leftNaviAll[$value] .= ' <li'; if((isset($LEVEL_ID[1]) && $LEVEL_ID[1] == $value)) { $_leftNaviAll[$value] .= ' class="active"'; $_isActive = true; } else { $_isActive = false; } $_leftNaviAll[$value] .= '><a href="index.php?'; $_leftNaviAll[$value] .= empty($content['struct'][$value]['acat_alias']) ? 'id='.$value : $content['struct'][$value]['acat_alias']; $_leftNaviAll[$value] .= '">'.html_specialchars($content['struct'][$value]['acat_name']).'</a>'; if($_isActive) { $_leftNaviAll[$value] .= buildCascadingMenu('F,'.$value.', , , active'); } $_leftNaviAll[$value] .= '</li>'.LF.'</ul>'; } $content['all'] = str_replace('{NAVIMAIN}', implode(LF.' ', $_mainNaviAll), $content['all']); $content['all'] = str_replace('{NAVILEFT}', implode(LF, $_leftNaviAll), $content['all']); ?>
Zur Erinnerung:
// Top Navigation $_mainNavi = array(0, 1, 2, 3); // Left Navigation $_leftNavi = array(4, 5, 6, 7, 8); // left navi IDs
Gegebene Struktur:
[0] Home [1] About Us [2] Contact [3] News [4] Product 1 [] sub1 product 1 [] sub2 product 1 [] sub3 product 1 [] .... [5] Product 2 [] .... [6] Product 3 [7] Product 4 [8] Product 5
Und wird im Frontend so gerendert:
<ul>[Home | About Us | Contact | News ]</ul> <ul html> [Product 1] <ul> [sub 1] [sub 2] [sub 3] </ul> </ul> <ul>[Product 2]</ul> <ul>[Product 3]</ul> <ul>[Product 4]</ul> <ul>[Product 5]</ul>
…usw. Versuche es - es ist recht einfach aber flexibel und kann mit der hilfe von CSS formatiert werden.
Verwende {NAVIMAIN} und {NAVILEFT} an der Stelle im Template, an der das Resultat erwcheinen soll…