Standardnavigationsmodul erweitern

Gesperrt
bibo
Beiträge: 4
Registriert: Do 23. Jun 2005, 16:20
Kontaktdaten:

Standardnavigationsmodul erweitern

Beitrag von bibo »

Hallo liebes Forum,
ich möchte meine Hauptnavigation mit einer zweiten Navigationsebene erweitern. Der Ist-Zustand (siehe unten) belebt nur eine Ebene. wie kann ich den Code aktualisieren, um eine 2. Ebene zu erhalten.

Vielen Dank im Voraus
bibo

Eingabe:

Code: Alles auswählen

// selected category
$selected = "CMS_VALUE[0]";
 
echo "<table cellspacing=\"0\" cellpadding=\"10\" border=\"0\">
        <tr valign=\"top\">
          <td>Kategorie wählen:</td>
          <td>
            <select name=\"CMS_VAR[0]\">";
            if($selected!="0" && $selected!=""){
             echo"<option value=\"0\">--- kein ---</option>";
 
            }else{
            echo"<option selected=\"selected\" value=\"0\">--- kein ---</option>";
            }
 
            // fetch all categorys
            $query = "SELECT A.idcat, A.level, C.name FROM ".$cfg["tab"]["cat_tree"]." AS A, ".
                     $cfg["tab"]["cat"]." AS B,  ".$cfg["tab"]["cat_lang"]." AS C WHERE A.idcat=B.idcat ".
                     "AND B.idcat=C.idcat AND C.idlang='$lang' AND B.idclient='$client' ".
                     "AND C.visible=1 ORDER BY A.idtree";
            // execute query
            $db->query($query);
 
            // loop result and build the options
            while ($db->next_record()) {
 
              // indent spacer
              $spaces = "|";
 
              // how many levels
              $levels = $db->f("level");
 
              for ($i = 0; $i < $levels; $i ++) {
                // add 2 spaces for every level
                $spaces = $spaces . "--";
 
              } // end for
              
              $spaces .= ">";
 

              if ($selected == $db->f("idcat")) {
                // selected category
                echo "<option selected=\"selected\" value=\"". $db->f("idcat") ."\">". $spaces . $db->f("name") ."</option>";
 
              } else {
                // category
                echo "<option value=\"". $db->f("idcat") ."\">". $spaces . $db->f("name") ."</option>";
 
              } // end if
 
            } // end while
 
echo "      </select>";
 
echo "    </td>
        </tr>
      </table>";

Ausgabe:

Code: Alles auswählen


<?php

include_once($cfg["path"]["contenido"].$cfg["path"]["includes"]."functions.con.php");

//?bergeordnete Kategorie, d.h. die ausgew?hlte Men?leiste
$catStart = "CMS_VALUE[0]";

function get_hm_cat_recursive($preid){
 global $cfg, $db, $lang, $catStart, $cat_array;
 $sql = "SELECT CAT.idcat AS idcat, name, postid, CATLANG.visible AS visible FROM ".
               $cfg["tab"]["cat"]." AS CAT, ".
               $cfg["tab"]["cat_lang"]." AS CATLANG 
               WHERE CAT.parentid = ".$catStart."
               AND CAT.idcat = CATLANG.idcat
               AND CATLANG.idlang = '$lang'
               AND CAT.preid ='".$preid."'";
//               AND CATLANG.visible = '1'
 
 $db->query($sql);
 $db->next_record();
 if ($db->f("visible")==1){
 	$cat_array[$db->f("idcat")]=$db->f("name"); // erstes Element in das Array einfügen;
 }
 
 if($db->f("postid")){
 	get_hm_cat_recursive($db->f("idcat"));	
 }	
 
}

/*
function getCurrentmenue($idcat) {
    global $cfg, $db, $lang, $menueArray;
    
    $sql = "SELECT
                a.name AS name,
                a.idcat AS idcat,
                b.parentid AS parentid
            FROM
                ".$cfg["tab"]["cat_lang"]." AS a,
                ".$cfg["tab"]["cat"]." AS b
            WHERE
                a.idlang    = '".$lang."' AND
                b.idcat     = '".$idcat."' AND
                a.idcat     = b.idcat";
                
    $db->query($sql);
    $db->next_record();

    $name       = $db->f("name");
    $parentid   = $db->f("parentid");

    if ( $parentid != 0 ) {
//		echo "ParentId: $parentid<br>";
		$menueArray[] = $parentid;
        getCurrentmenue($parentid);
    } else {
		if (sizeof($menueArray) < 2) {
			$GLOBALS["currentmenue"] = $GLOBALS["idcat"];
		} else {
			$GLOBALS["currentmenue"] = $menueArray[sizeof($menueArray)-2];
		}
	}

}
*/

$login_only_cats = array ('59', '60', '61', '63','64','65');
$logout_only_cats = array ('62', '8');


if ($catStart != "") {
	echo '<table cellpadding="0" cellspacing="0" border="0" width="180">';		 
	$cat_array=array();
	// erster Aufruf der Rekursion mit preid=0, 
	get_hm_cat_recursive(0);
	
	$rows = count($cat_array);
	$i=1;

/*
	$menueArray = array();
//	echo "idcat: ".$idcat."<br>"; 
	getCurrentmenue($idcat);

//	echo "currentmenue: ".$currentmenue."<br>";
	print_r($menueArray);
*/
	$spacer_cell="<td class=\"hauptNavi\"><img src=\"./images/1x1.gif\" width=\"10\" height=\"1\"></td>";
	$on_image="images/hauptnavi.gif";
	$off_image="images/hauptnavi_off.gif";
	$image_width="24";
	$image_height="10";
 
//        while ( $db->next_record() ) {					
	foreach ($cat_array as $catid => $name){

if($catid==15){
$spacer = '<br><br>';
}
else{
$spacer= '';
}


			$imgname="hm_item_".$catid;  // Bildbezeichnung, wird für den Mouseover-Effekt gebraucht
 
			if($catid==$currentmenue) { // aktiver Menüpunkt

				echo '<tr><td class="hauptNavi"><a href="'.$_SERVER["PHP_SELF"].'?idcat='.$catid.'&currentmenue='.$catid.'&idlang='.$lang.'">'.$spacer.'<b>'.$name.'</b></a></td></tr>';		  

			} else { // inaktive Men?punkte

				echo '<tr><td class="hauptNavi"><a href="'.$_SERVER["PHP_SELF"].'?idcat='.$catid.'&currentmenue='.$catid.'&idlang='.$lang.'">'.$spacer.''.$name.'</a></td></tr>';
			}
	
			$i++;
	}//foreach
 
	echo '</table>';
 
}//if

?>
emergence
Beiträge: 10653
Registriert: Mo 28. Jul 2003, 12:49
Wohnort: Austria
Kontaktdaten:

Beitrag von emergence »

ähm das ist keine standardnavigation so wie sie in einer der demomandanten zu finden ist...

sich in den code reinzudenken ist mir bei der hitze momentan nicht möglich...

sieh dir bitte mal das modul hauptnavigation des demomandanten an...
dort siehst du wie das gemacht werden müsste...
*** make your own tools (wishlist :: thx)
Gesperrt