Seite 1 von 1

Navigation in Selectbox

Verfasst: Do 15. Mai 2008, 11:53
von deadalus
hallo zusammen,

ich bin auf der suche nach einem modul was mir bestimmte kategorien als selectbox ausgibt.
hir im forum habe ich mal folgendes modul entdeckt:

INPUT:

Code: Alles auswählen

/**
* Artikelliste mit I1,H1,T1
*
* Erstellt eine Liste mit allen Artikel bis
* auf den Startartikel.
*
* INPUT
*
* Author Jan Lengowski
* Copyright four for business AG
*/

// 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>
        <tr>
          <td>Überschrift</td>
          <td><input type=\"text\" name=\"CMS_VAR[2]\" value=\"CMS_VALUE[2]\"></td>
        </tr>
        <tr>
          <td>Angezeigte Länge in Zeichen</td>
          <td><input type=\"text\" name=\"CMS_VAR[3]\" value=\"CMS_VALUE[3]\"></td>
        </tr>

      </table>";

OUTPUT:

Code: Alles auswählen

<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* ARTIKELLISTE
*
* Erstellt eine Liste mit allen Artikel bis
* auf den Startartikel.
*
* Basierend auf dem Modul von Jan Lengowski
************************************************/


// second db class instance
$db2 = new DB_Contenido;

// selected category
$selcat = "CMS_VALUE[0]";

 if($selcat!="0" && $selcat!=""){

// select all articles in category widthout start article
$query = "SELECT ARTLANG.idart, ARTLANG.idartlang FROM ".$cfg["tab"]["cat_art"]." AS CATART, ".
          $cfg["tab"]["art_lang"]." AS ARTLANG ".
         "WHERE CATART.idcat = '$selcat' AND ARTLANG.idart = CATART.idart AND ARTLANG.idlang = '$lang' AND ".
         "ARTLANG.online = '1' ORDER BY ARTLANG.title DESC";

// execute query
$db->query($query);

unset($articleID);
unset($linkID);

// get id's of sub articles
while ($db->next_record()) {
  $articleID[] = $db->f("idartlang");
  $linkID[] = $db->f("idart");
} // end while

// loop through subarticles

echo '
<form name="form">
<select name="link" class="formObj" onChange="window.location.href = document.form.link.options[document.form.link.selectedIndex].value;">
<option selected>Bitte ausw&auml;hlen...</option>
';

if (is_array($articleID)) {

    foreach ($articleID as $key => $value) {

          // select all CMS variables of the article
          $sql = "SELECT * FROM ".$cfg["tab"]["content"]." WHERE idartlang = '$value' AND idtype = '1' AND typeid = '1'";
          $db->query($sql);
          $db->next_record();
          $head = $db->f("value");

          if ( strlen($head) > "CMS_VALUE[3]") {
            $head = substr($head, 0, "CMS_VALUE[3]");
            $head .= '..';
          }

          // link
          $link = $sess->url("front_content.php?client=$client&lang=$lang&idcat=$selcat&idart=$linkID[$key]&m=$m&s=$s");
       
          echo '<option value="'.$link.'">'.urldecode($db->f("value")).'</option>';

    } // end while



          unset($headline);
        unset($text);
       
    } // end foreach
   
} // end if (is_array)

echo '</select></form>';


?> 

das liest aber leider nur die artikel der ersten kategorie aus. alle weiteren werden ignoriert.
lässt sich das so umschreiben das anstelle der artikel die kategorien angezeigt werden?
oder gibt es hier irgendwo schon ein ähnliches modul? habe auch nach langem suchen nichts anderes finden könne. mir ist besonders der selectbox aspekt wichtig!

danke schonmal

Re: Navigation in Selectbox

Verfasst: Do 15. Mai 2008, 12:48
von tono
deadalus hat geschrieben:lässt sich das so umschreiben das anstelle der artikel die kategorien angezeigt werden?
Im Prinzip ja, aber es wäre einfacher ein Navigationsmodul, das mit Kategorien arbeitet umzuschreiben, z.B. Hilfsnavigation oder Hauptnavigation aus dem Beispielmandanten.

Verfasst: Fr 16. Mai 2008, 15:30
von deadalus
hat zufällig jemand so ein abgeändertes navigations modul rumliegen? meine php kenntnisse langen leider nicht aus um das standart modul anzupassen.

Verfasst: Fr 23. Mai 2008, 11:37
von deadalus
habs selbst hinbekommen...

danke

Verfasst: Sa 24. Mai 2008, 16:14
von tono
Bitte.

Da Du es jetzt ja rumliegen hast, wie wärs mit veröffentlichen? Vielleicht brauchts jemand?

Verfasst: Mo 2. Jun 2008, 15:15
von deadalus
ok also ein paar probleme hab ich noch:
das modul liest nur die kategorien der gewählten ebene aus. könnte man dem beibringen das es auch die erste ebene darunter mit ausgibt?

Code: Alles auswählen

<?php


cInclude("frontend", "includes/functions.navigation.php");
cInclude('classes', 'class.template.php');
	
$catStart = "CMS_VALUE[0]";
if(($catStart=='')||($catStart=='0')){
    $cApiClient = new cApiClient($client);
    $catStart= $cApiClient->getProperty('navigation', 'idcat_hilfsnavi');
}
if(!is_object($oClient)) {
	$oClient = new cApiClient($client);
}

$navigation = array();
$navigation = createNavigationArray($catStart, $db);

if (count($navigation) > 0) { 
	foreach ($navigation as $key => $data) {
		echo '<option value="'.$sess->url('front_content.php?idcat='.$data['idcat']).'">'.$data['name'].'</option>';
	} 
}

//switch($lang){
//	case '2':
//		//englisch -> deutsch
//		echo '<a href="'.$sess->url('front_content.php?changelang=1').'" class="dropdown">'.mi18n("Deutsch").'</a>';
//		break;
//	default:
//		//deutsch -> englisch
//		echo '<a href="'.$sess->url('front_content.php?changelang=2').'" class="dropdown">'.mi18n("English").'</a>';
//		break;
//}
?>


beim einfügen ins layout muss man noch den container mit dem zusatz:

Code: Alles auswählen

<form name="form">
<select name="link" class="formObj" onChange="location.href=this.options[this.selectedIndex].value">
<option selected>Anwendungen</option><container id="21" name="Finder" types="Content" default="Finder">Finder</container></select></form>
integrieren...
der input ist der selbe wie bei der hilfsnavigation