Nachdem ich ein Modul benötige mit dem ich durch die einzelnen Unterkategorien durchnavigieren kann und hier keines gefunden habe hab ich selbst was geschrieben...
Nur will das Ding noch nicht ganz so wie ich will...
Vielleicht weiss ja jemand von Euch woran es liegt...
Das Problemchen ist jetzt gelöst...
Das Modul sollte jetzt ohne Probleme funktionieren...
Es fehlt noch das Modultemplate das in dem Beispiel hier "impigra_CatNav.html" benannt ist.
Hier mal der Output:
Code: Alles auswählen
<?php
#Includes
cInclude('classes', 'class.template.php');
# impigra_CatNav.html
/**
* SQL Abfrage Contenido DB
*/
$kategorie = "CMS_VALUE[0]";
$mydb = new DB_Contenido;
$sql = "SELECT * 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 B.parentid=$kategorie
AND C.visible=1
AND C.public=1
ORDER by A.idtree";
$mydb->query($sql);
$cnt = 0;
$rs_rows = $mydb->num_rows();
// durch die Records semmeln...
while($mydb->next_record())
{
$i_cat[$cnt] = $mydb->f("idcat");
$i_name[$cnt] = $mydb->f("name");
if($mydb->f("idcat") == $idcat)
{
$current = $cnt;
}
$cnt++;
}
build_nav($current, $rs_rows);
function build_nav($cur_index, $rows)
{
global $i_cat, $i_name;
echo 'current index' . $cur_index . '<br>';
//index angleichen
$rows = $rows - 1;
echo 'rows-1' . $rows . '<br><br>';
// wenn current in der mitte...
if($cur_index > 0 && $cur_index < $rows)
{
$prev_index = $cur_index - 1;
$next_index = $cur_index + 1;
}
// wenn current am Anfang
else
{
if($cur_index == 0)
{
$prev_index = '';
$next_index = $cur_index + 1;
}
if($cur_index == ($rows))
// wenn current am Ende
{
$prev_index = $cur_index - 1;
$next_index = '';
}
}
// Template
$tpl = new Template;
$tpl->reset();
$template = 'impigra_CatNav.html';
if($prev_index != '')
{
$tpl->set('s', 'PREV_LINK', 'front_content.php?idcat='.$i_cat[$prev_index]);
$tpl->set('s', 'PREV_TEXT', $i_name[$prev_index]);
}
else
{
$tpl->set('s', 'PREV_LINK', '');
$tpl->set('s', 'PREV_TEXT', '');
}
if($next_index != '')
{
$tpl->set('s', 'NEXT_LINK', 'front_content.php?idcat='.$i_cat[$next_index]);
$tpl->set('s', 'NEXT_TEXT', $i_name[$next_index]);
}
else
{
$tpl->set('s', 'NEXT_LINK', '');
$tpl->set('s', 'NEXT_TEXT', '');
}
$tpl->generate('templates/'.$template);
// End Function
}
?>
Input:
Code: Alles auswählen
/***********************************************
* CONTENIDO MODUL - INPUT
*
* Modulname : impigra::CatNav
* Author : Christian Müller
* Copyright : Christian Müller
* Created : 2008-08-01
* Modified : 2008-08-02
* Credits : Ingo van Peeren (vpSitemap)
************************************************/
$selected = "CMS_VALUE[0]";
?>
<table cellspacing="0" cellpadding="10" border="0">
<tr valign="top">
<td>Oberkategorie wählen:</td>
<td><?php echo "<select name=\"CMS_VAR[0]\">";?>
<option value="0">---Alle---</option>
<?php
// alle Kategorien auslesen
$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";
// Query ausführen
$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
echo "<option";
if ($selected == $db->f("idcat")) echo " selected=\"selected\"";
echo " value=\"". $db->f("idcat") ."\">". $spaces . "->" . $db->f("name") . "</option>";
} // end while
?>
</select>
</td>
</tr>
</table>
<?php
Viel Spass mit dem Ding
