Service Nav 1 -> Aktiver Link wenn keine Kategorie active
Verfasst: Fr 22. Jul 2005, 20:34
Wie kann ich in der Service Nav 1 folgendes realisieren:
Wenn keine Kategorie (> Ebene 0) "activated" ist, soll immer automatisch meine erste Kategorie in Ebene 1 "activated" sein.
Hintergrund: Wenn ich eine Seite a la domain.tld aufrufe, ist ja erstmal keine Kategorie aktiv. Es sei denn, ich leite meine idcat=1 auf die entsprechende Home-Kategorie weiter. Das will ich aber vermeiden. Es soll aber dennoch "Home" in meiner Navigation "activated" werden.
Ich hoffe ich habe mich einigermaßen verständlich ausgedrückt..
Hier das verwendete Modul:
Wenn keine Kategorie (> Ebene 0) "activated" ist, soll immer automatisch meine erste Kategorie in Ebene 1 "activated" sein.
Hintergrund: Wenn ich eine Seite a la domain.tld aufrufe, ist ja erstmal keine Kategorie aktiv. Es sei denn, ich leite meine idcat=1 auf die entsprechende Home-Kategorie weiter. Das will ich aber vermeiden. Es soll aber dennoch "Home" in meiner Navigation "activated" werden.
Ich hoffe ich habe mich einigermaßen verständlich ausgedrückt..
Hier das verwendete Modul:
Code: Alles auswählen
<?php
/******************************************
* File : Service Nav 1 CSS
* Project : Contenido
* Descr : Output Modul
*
* Author : unknown
* modified : Florian Behrendt
* Created : 01.03.2005
* Modified : 01.03.2005
*
* Version : 1.0
* © GPL ?
*****************************************/
include_once($cfg["path"]["contenido"].$cfg["path"]["includes"]."functions.con.php");
if (!function_exists("catIsChildOf")) // Function nur neu, falls sie noch nicht exisitiert!
{
function catIsChildOf($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;
} //End Function ("catIsChildOf"))
}
// Endif (!function_exists("catIsChildOf"))
$catStart="CMS_VALUE[0]";
if ($catStart != "") {
$catIds = conDeeperCategoriesArray($catStart);
echo '
<div id="headnav">
<ul class="list-snav-1">'; // erstes Listenelemment
if ( is_array($catIds) ) {
foreach($catIds as $key=>$val) {
// Ersten Eintrag ueberspringen, weil das der Menupunkt selbst ist
// und nicht angezeigt werden soll.
if ($key != 0) {
$sql = "SELECT CAT.idcat AS idcat, name FROM ".
$cfg["tab"]["cat"]." AS CAT, ".
$cfg["tab"]["cat_lang"]." AS CATLANG, ".
$cfg["tab"]["cat_tree"]." AS CATTREE
WHERE CAT.idcat = ".$val."
AND CAT.idcat = CATLANG.idcat
AND CATTREE.idcat = CAT.idcat
AND CATLANG.idlang = '$lang'
AND CATTREE.level = '1'
AND CATLANG.visible = '1'";
$db->query($sql);
$db2 = new DB_Contenido;
while ( $db->next_record() ) {
$target = "_self";
/* Check for redirect and new window flag */
$sql = "SELECT idart FROM ".
$cfg["tab"]["cat_art"]."
WHERE idcat='". $db->f("idcat")."'
AND is_start = '1'";
$db2->query($sql);
if ($db2->next_record())
{
$cidart = $db2->f("idart");
$sql = "SELECT external_redirect FROM ".
$cfg["tab"]["art_lang"]."
WHERE idart = '$cidart'
AND idlang='$lang'";
$db2->query($sql);
if ($db2->next_record())
{
$target = ( $db2->f("external_redirect") == 0 ) ? '_self' : '_blank';
}
}
// jetzt kommt die Abfrage ob aktiver Menüpunkt um den Hintergrund zu setzen
// zunächst normale Abfrage ob aktiver Menüpunkt.
if ($idcat == $db->f("idcat")) {
// if ( catIsChildOf($idcat, $db->f("idcat"))) {
echo '
<li class="snav-1 activated">
<a target="'.$target.'" href="front_content.php?idcat='.$db->f("idcat").'">
'.$db->f("name").'
</a></li>
';}// End if
// Abfrage ob übergeordnete Kategorie, für Unterpunkte.
// if ($idcat == $db->f("idcat")) {
elseif ( catIsChildOf($idcat, $db->f("idcat"))) {
echo '
<li class="snav-1 activated">
<a target="'.$target.'" href="front_content.php?idcat='.$db->f("idcat").'">
'.$db->f("name").'
</a></li>
';}// End if if ($idcat == $data['idcat'] || is_array($data['sub']))
else
{
echo '<li class="snav-1 inactive">
<a target="'.$target.'" href="front_content.php?idcat='.$db->f("idcat").'">
'.$db->f("name").'
</a></li>
';}// End else if ($idcat == $data['idcat'] || is_array($data['sub']))
} // end while
} // if
} // end foreach
} // end if (is_array)
echo '<li class="stinger"> </li></ul></div>';
}
?>