Seite 1 von 1

Navigations Modul Problem

Verfasst: Do 24. Feb 2005, 23:03
von w0nd3r
Hallo Leute,

hänge derzeit an einem Problem an dem ich nicht weiter komme und eure Hilfe brauche!:wink:

Ich poste nun den Code des Navigationsmoduls:

Input:

Code: Alles auswählen

?>
<table cellspacing="0" cellpadding="0" cellpadding="4">

    <tr>
        <td class="text">Baum wählen:</td>
        <td>
            <select name="CMS_VAR[100]">
            <option value="0">-- kein --</option>
            <?php

                $sql = "SELECT
                            A.idcat,
                            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 AND
                            A.level     = '0'
                        ORDER BY
                            A.idtree";

                $db->query($sql);

                while ( $db->next_record() ) {

                    if ( "CMS_VALUE[100]" == $db->f("idcat") ) {
                        echo '<option selected="selected" value="'.$db->f("idcat").'">'.$db->f("name").'</option>';

                    } else {
                        echo '<option value="'.$db->f("idcat").'">'.$db->f("name").'</option>';

                    }
                }

            ?>
            </select>
        </td>
    </tr>
    <tr>
        <td class="text">LI-Tag - Aktive Klasse w&auml;hlen:</td>
            <td>
	        <input type="text" name="CMS_VAR[101]" value="CMS_VALUE[101]">
	   </td>
    </tr>
    <tr>
        <td class="text">A-Tag - Aktive Klasse w&auml;hlen:</td>
            <td>
	        <input type="text" name="CMS_VAR[102]" value="CMS_VALUE[102]">
	   </td>
    </tr>

</table>

<?php
Output:

Code: Alles auswählen

<?php
function nav_generate($int_id = 0) {
	
	global $cfg, $client, $lang, $sess, $idcat, $arr_tree;
	
	foreach($arr_tree as $int_temp_cat_id) {
		if ($int_temp_cat_id == $int_id) {
			$db = new DB_Contenido;
	
			// Kategorie Namen auslesen aus CON_CAT_LANG	
					$sql_kategorien = "      SELECT 
					 		 			 cl.name,
					  					 c.idcat
              		 		  			 FROM
					 		 			 ".$cfg["tab"]["cat"]." c,
					 					 ".$cfg["tab"]["cat_lang"]." cl,
							   			 ".$cfg["tab"]["cat_tree"]." ct
							   	 WHERE
							   			 c.idcat = cl.idcat AND
                   		    			                         cl.idlang = ".$lang." AND
			                  		                         c.idclient = ".$client." AND
						  			         c.idcat = ct.idcat AND
							   			 c.parentid = ".$int_id."
						                 ORDER BY
							                         ct.idtree";
	
					 $db->query($sql_kategorien);
					 $int_num_rows = $db->num_rows();
	
					 if ( $int_num_rows > 0 ) {
					 
						print "<ul>";	
	
						while($db->next_record()) {
						
							$str_style_li = "";
							$str_style_a  = "";
							
							foreach($arr_tree as $int_active_id) {
							
							if ( $int_active_id == $db->f('idcat')) {							
							
								if ( strlen("CMS_VALUE[101]") > 0 ) {
									$str_style_li  = ' class="';
									$str_style_li .= "CMS_VALUE[101]";
									$str_style_li .= '"';
								}

								if ( strlen("CMS_VALUE[102]") > 0 ) {
									$str_style_a  = ' class="';
									$str_style_a .= "CMS_VALUE[102]";
									$str_style_a .= '"';
								}
								
							}// if
							}
							
							print "<li" . $str_style_li . ">";
							
							print '<a' . $str_style_a . ' href="' . $sess->url('front_content.php?idcat='.$db->f('idcat')). '">' . $db->f("name") . ' </a>';	
		
							nav_generate( $db->f('idcat'));				
			
							print "</li>";
						}	
	
						print "</ul>";
					}
		}//if
	}// foreach	
}// functiuon

$arr_tree = array($idcat);

function do_hnav () {
	global $idcat, $arr_tree;
	
	$db = new DB_Contenido; 	
	
 	$int_parent_id = $idcat;
	
	while ( $int_parent_id > 0 ) {
		$sql_navarray = "SELECT
				         parent_id
				 FROM	
					 ".$cfg["tab"]["cat"]."
				 WHERE
					 idcat = " . $int_parent_id ; 
						 
		$db->query($sql_navarray);
		$int_parent_id = $db->f('parent_id');
		$arr_tree[] = $db->f('parent_id');
		
		if ( "CMS_VALUE[100]" ==  $db->f('parent_id')) {
			break;
		}
	}	
	nav_generate();
}
	

do_hnav();

?>
Mein Problem ist nun das Ich z.B. ein Navigationsbaum wie folgt habe:

Navigation
->Home
->Produkte
->Leistungen
->Kontakt
->Impressum

Bei dem bei dem obigen Modul wird leider NUR der Baumname selbst angezeigt und nicht die eigentlich relevanten Navigationspunkte.

Er gibt also nur "Navigation" aus anstatt "Home". "Produkte", etc..

Für eure Hilfe wäre ich euch sehr dankbar. :roll:

Grüße
w0nd3r

Verfasst: Fr 25. Feb 2005, 10:45
von Beleuchtfix
Ich hätte da auch mal gern ein Problem :wink:

Es gibt diverse Navigations-Module, warum will jeder als erstes ein neues Modul schreiben?

Also konkret, was ist der Vorteil von deiner Navigation? Erst wenn ich das verstehe, würde ich mir die Mühe machen, in so ein Problem einzudenken.

Viel Erfolg
Florian

Verfasst: Fr 25. Feb 2005, 13:46
von w0nd3r
Es ist ein rekrusives Modul, daher weniger Code, und besser durchdacht als die Standard Module.