Hauptnavigation: CSS-Problem Farben
Verfasst: Do 3. Mär 2005, 12:18
Ich nutze die zweigeteilte Navigation und habe jeder Kategorie ein eigenes Farbschema zugewiesen. Das funktioniert auch ohne Probleme.
Mein problem ist nun, dass dieses Farbschema erst nach Aufruf einer Katgeorie sichtbar ist.
Ich hätte es aber gerne, dass beireits in der Menüleiste der Hauptnavigation die Farbzuordnungen angezeigt werden. D.h. ich müsste jedem Hauptmenüpunkt eine ander Klasse oder ID zuweisen und dann mittels css die Formatierungen vornehmen.
Über das Navigationstemplate geht das nicht. Da bekommen alle Hauptmenuüunkte ein identisches Design.
Hier der Code der Hauptnavigation:
Theoretisch müsste ich wahrscheinlich dem Menülink eine Klasse zuweisen, deren Name sich aus einem festen bestandteil (z.B.mainnav) und der idcat der Kategorie zusammensetzt. Daraus würde dann z.B. mainav1, mainav2 etc. Aber wie geht das? Kann mir da vielleicht jemand weiterhelfen?
Als PHP-Laie würde ich vermuten, dass eine Änderung in dem Bereich
erforderlich ist.
Weiss jemand was man genau ändern muss? Das wäre super.
Mein problem ist nun, dass dieses Farbschema erst nach Aufruf einer Katgeorie sichtbar ist.
Ich hätte es aber gerne, dass beireits in der Menüleiste der Hauptnavigation die Farbzuordnungen angezeigt werden. D.h. ich müsste jedem Hauptmenüpunkt eine ander Klasse oder ID zuweisen und dann mittels css die Formatierungen vornehmen.
Über das Navigationstemplate geht das nicht. Da bekommen alle Hauptmenuüunkte ein identisches Design.
Hier der Code der Hauptnavigation:
Code: Alles auswählen
/******************************************************************
*
* CONTENIDO MODUL
*
* Hauptnavigation - als unabhängiges Modul zur Unternavigation
*
* Zwei Module werden benötigt und hier beschrieben
*
* Mit Hilfe dieser zwei Module kann man zum Beispiel
* eine Horizontale Hauptnavigation in einem Container
* und eine vertikale Unternavigation in einem anderen Container
* oder umgekehrt realisieren (oben Haupt- und links oder rechts Unternavigation.
*
* Um die Haupnnavigation oder Unternavigation horizontal einzustellen
* kopiert die nav["" | "second" | "third"]_["off" | [on].html
* nach nav["" | "second" | "third"]_h_["off" | [on].html
* (z.B. cp navsecond_off.html navsecond_h_off.html
* - liegen im Pfad .../contenido/cms/templates/) und
* schmeisst dort die Tabellen-Tags raus (die stehen jetzt schon im Modul)
*
* Orginal
* Modulname : Navigation 1.1
* Author : Jan Lengowski
* Copyright : Contenido - four for business
* Created : 15-05-2003
* Modified :26-05-2003
* Modified : by herby
* Modified : by yodatortenboxer
*
*******************************************************************
/******************************************************************
*Hauptnavigation Eingabe:
******************************************************************/
/**
* Navigation
*
* INPUT
*
* @autor Jan Lengowski <Jan.Lengowski@4fb.de>
* @copyright four for business AG 2003
*/
?>
<table cellspacing="0" cellpadding="0" cellpadding="4">
<tr>
<td class="text">Baum wählen:</td>
<td>
<select name="CMS_VAR[0]">
<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[0]" == $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>
</table>
<?php
/******************************************************************
*Hauptnavigation Ausgabe:
******************************************************************/
<?php
// Hauptnav
/***********************************************
* 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($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($idcat, CMS_VALUE[0]) ) {
$sel_idcat = $idcat;
} else {
$sel_idcat = CMS_VALUE[0];
}
/* Include Template Class */
include_once($cfg["path"]["contenido"] . 'classes/class.template.php');
/**
* Array storing alle the
* navigation data
*/
$navitems = array();
/* Template Instance */
$tpl = new Template;
/**
* Recursive function for creating
* the navigation array
* @param Int $idcat Category id
*/
function nav($idcat) {
global $navitems, $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[0] ){
$navitems = 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[0]'
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[$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;
$navitems = $tmp_nav;
/* Function call */
nav($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[$db->f("idcat")] = array("idcat" => $db->f("idcat"),
"name" => $db->f("name"),
"target" => $target);
}
/* Create Navigation Array */
nav($sel_idcat);
/* Start Output buffer */
ob_start();
echo '<table cellspacing="0" cellpadding="0" border="0"><tr><td>';
foreach ($navitems as $key => $data) {
/* 1. Navigations Ebene */
$tpl->reset();
$tpl->set('d', 'NAME', $data['name']);
$tpl->set('d', 'TARGET', $data['target']);
$tpl->set('d', 'HREF', $sess->url('front_content.php?idcat='.$data['idcat']));
$tpl->next();
if ($idcat == $data['idcat'] || is_array($data['sub'])) {
$tpl->generate('templates/navfirst_h_on.html');
} else {
$tpl->generate('templates/navfirst_h_off.html');
}
if (is_array($data['sub'])) {
$tmp_data = array();
$tmp_data = $data;
} // end if
} // end foreach
echo '</td></tr></table>';
/* Read out buffer */
$html = ob_get_contents();
/* Clean buffer */
ob_end_clean();
/* Output buffer-contents */
echo $html;
?>
Als PHP-Laie würde ich vermuten, dass eine Änderung in dem Bereich
Code: Alles auswählen
echo '<table cellspacing="0" cellpadding="0" border="0"><tr><td>';
foreach ($navitems as $key => $data) {
/* 1. Navigations Ebene */
$tpl->reset();
$tpl->set('d', 'NAME', $data['name']);
$tpl->set('d', 'TARGET', $data['target']);
$tpl->set('d', 'HREF', $sess->url('front_content.php?idcat='.$data['idcat']));
$tpl->next();
if ($idcat == $data['idcat'] || is_array($data['sub'])) {
$tpl->generate('templates/navfirst_h_on.html');
} else {
$tpl->generate('templates/navfirst_h_off.html');
}
if (is_array($data['sub'])) {
$tmp_data = array();
$tmp_data = $data;
} // end if
} // end foreach
echo '</td></tr></table>';
Weiss jemand was man genau ändern muss? Das wäre super.