vielleicht brauchts jemand.
Das ist ein Navigationsmodul, welches einen zweiten Baum anzeigt (wie Hauptnavigation). Zusätzlich wird die Navigation nicht angezeigt, wenn der user nicht eingeloggt ist.
Das Modul ist von mir nur leicht geändert.
getestet unter Contenido 4.4.4.
Code: Alles auswählen
input
// selected category
$selected = "CMS_VALUE[9000]";
echo "<table cellspacing=\"0\" cellpadding=\"10\" border=\"0\">
<tr valign=\"top\">
<td>Kategorie wählen:</td>
<td>
<select name=\"CMS_VAR[9000]\">";
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>";
Code: Alles auswählen
<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname : Navigation 1.1
* Author : Jan Lengowski
* Copyright : Contenido - four for business
* Created : 15-05-2003
* Modified : 26-05-2003
************************************************/
if ( !is_object($db2) ) {
$db2 = new DB_Contenido;
}
/**
* Check if a category is child
* of another category
*
* @return boolean true/false
* @author Jan Lengowski <Jan.Lengowski@4fb.de>
* @copyright four for business AG 2003
*/
function catischildof_mod2($id, $idparent) {
global $cfg, $client, $lang;
$db = new DB_Contenido;
$parent = $id;
while ( $parent != 0 ) {
$sql = "SELECT
a.parentid
FROM
".$cfg["tab"]["cat"]." AS a,
".$cfg["tab"]["cat_lang"]." AS b
WHERE
a.idclient = '".$client."' AND
b.idlang = '".$lang."' AND
a.idcat = b.idcat AND
a.idcat = '".$parent."'";
$db->query($sql);
$db->next_record();
$parent = $db->f("parentid");
if ($parent == $idparent) {
return true;
}
}
return false;
}
if ( catischildof_mod2($idcat, CMS_VALUE[9000]) ) {
$sel_idcat = $idcat;
} else {
$sel_idcat = CMS_VALUE[9000];
}
/* Include Template Class */
include_once($cfg["path"]["contenido"] . 'classes/class.template.php');
/**
* Array storing alle the
* navigation data
*/
$navitems_mod2 = array();
/* Template Instance */
$tpl_mod2 = new Template;
/**
* Recursive function for creating
* the navigation array
* @param Int $idcat Category id
*/
function nav_mod2($idcat) {
global $navitems_mod2, $client, $lang, $cfg;
$db = new DB_Contenido;
$db2 = new DB_Contenido;
$sql = "SELECT parentid FROM ".$cfg["tab"]["cat"]." WHERE idcat = '$idcat'";
$db->query($sql);
$db->next_record();
$parentid = $db->f("parentid");
if ( $parentid == 0 ) {
if ( $idcat != CMS_VALUE[9000] ){
$navitems_mod2 = array();
$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
B.idclient = '$client' AND
C.idlang = '$lang' AND
C.visible = '1' AND
B.parentid = 'CMS_VALUE[9000]'
ORDER
BY A.idtree";
$db->query($sql);
while ($db->next_record()) {
/* Check for external redirects... */
$sql = "SELECT
a.external_redirect AS ext
FROM
".$cfg["tab"]["art_lang"]." AS a,
".$cfg["tab"]["cat_art"]." AS b,
".$cfg["tab"]["cat"]." AS c
WHERE
b.idcat = '".$db->f("idcat")."' AND
b.is_start = '1' AND
c.idclient = '".$client."' AND
c.idcat = b.idcat AND
a.idart = b.idart AND
a.idlang = '".$lang."'";
$db2->query($sql);
$db2->next_record();
$target = ( $db2->f("ext") == 0 ) ? '_self' : '_blank';
$navitems_mod2[$db->f("idcat")] = array("idcat" => $db->f("idcat"),
"name" => $db->f("name"),
"target" => $target);
}
}
return true;
}
$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
B.idclient = '$client' AND
C.idlang = '$lang' AND
C.visible = '1' AND
B.parentid = '$parentid'
ORDER BY
A.idtree";
$db->query($sql);
while ($db->next_record()) {
/* Check for external redirects... */
$sql = "SELECT
a.external_redirect AS ext
FROM
".$cfg["tab"]["art_lang"]." AS a,
".$cfg["tab"]["cat_art"]." AS b,
".$cfg["tab"]["cat"]." AS c
WHERE
b.idcat = '".$db->f("idcat")."' AND
b.is_start = '1' AND
c.idclient = '".$client."' AND
c.idcat = b.idcat AND
a.idart = b.idart AND
a.idlang = '".$lang."'";
$db2->query($sql);
$db2->next_record();
$target = ( $db2->f("ext") == 0 ) ? '_self' : '_blank';
$tmp_nav[$db->f("idcat")] = array("idcat" => $db->f("idcat"),
"name" => $db->f("name"),
"target" => $target);
}
$tmp_nav[$idcat]["sub"] = $navitems_mod2;
$navitems_mod2 = $tmp_nav;
/* Function call */
nav_mod2($parentid);
} // end function
$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
B.idclient = '$client' AND
C.idlang = '$lang' AND
C.visible = '1' AND
B.parentid = '$sel_idcat'
ORDER BY
A.idtree";
$db->query($sql);
while ( $db->next_record() ) {
/* Check for external redirects... */
$sql = "SELECT
a.external_redirect AS ext
FROM
".$cfg["tab"]["art_lang"]." AS a,
".$cfg["tab"]["cat_art"]." AS b,
".$cfg["tab"]["cat"]." AS c
WHERE
b.idcat = '".$db->f("idcat")."' AND
b.is_start = '1' AND
c.idclient = '".$client."' AND
c.idcat = b.idcat AND
a.idart = b.idart AND
a.idlang = '".$lang."'";
$db2->query($sql);
$db2->next_record();
$target = ( $db2->f("ext") == 0 ) ? '_self' : '_blank';
$navitems_mod2[$db->f("idcat")] = array("idcat" => $db->f("idcat"),
"name" => $db->f("name"),
"target" => $target);
}
/* Create Navigation Array */
nav_mod2($sel_idcat);
/* Start Output buffer */
ob_start();
if ($auth->auth[uname] != "nobody")
{
echo '<table width="185" cellspacing="0" cellpadding="0" border="0">';
foreach ($navitems_mod2 as $key => $data) {
/* 1. Navigations Ebene */
$tpl_mod2->reset();
$tpl_mod2->set('d', 'NAME', $data['name']);
$tpl_mod2->set('d', 'TARGET', $data['target']);
$tpl_mod2->set('d', 'HREF', $sess->url('front_content.php?idcat='.$data['idcat']));
$tpl_mod2->next();
if ($idcat == $data['idcat'] || is_array($data['sub'])) {
$tpl_mod2->generate('templates/navfirst_on.html');
} else {
$tpl_mod2->generate('templates/navfirst_off.html');
}
if (is_array($data['sub'])) {
foreach ($data['sub'] as $key => $data) {
/* 2. Navigations Ebene */
$tpl_mod2->reset();
$tpl_mod2->set('d', 'NAME', $data['name']);
$tpl_mod2->set('d', 'TARGET', $data['target']);
$tpl_mod2->set('d', 'HREF', $sess->url('front_content.php?idcat='.$data['idcat']));
$tpl_mod2->next();
if ($idcat == $data['idcat'] || is_array($data['sub'])) {
$tpl_mod2->generate('templates/navsecond_on.html');
} else {
$tpl_mod2->generate('templates/navsecond_off.html');
}
if (is_array($data['sub'])) {
foreach ($data['sub'] as $key => $data) {
/* 3. Navigations Ebene */
$tpl_mod2->reset();
$tpl_mod2->set('d', 'NAME', $data['name']);
$tpl_mod2->set('d', 'TARGET', $data['target']);
$tpl_mod2->set('d', 'HREF', $sess->url('front_content.php?idcat='.$data['idcat']));
$tpl_mod2->next();
if ($idcat == $data['idcat']) {
$tpl_mod2->generate('templates/navthird_on.html');
} else {
$tpl_mod2->generate('templates/navthird_off.html');
}
} // end foreach
} // end if
} // end foreach
} // end if
} // end foreach
echo '</table>';
}
/* Read out buffer */
$html_mod2 = ob_get_contents();
/* Clean buffer */
ob_end_clean();
/* Output buffer-contents */
echo $html_mod2;
?>