
DESCRIPTION
Code: Alles auswählen
tt_navigation v. 0.8 alpha / copyright by NETSPIRIT GmbH www.netspirit.ch
This is a Multi -Layer-, -Language-, -Client-, -Container-, -Template-Navigation-Module for Contenido 4.5
Installation:
1. place the tt_navigation_include.php in contenido/includes/ folder
2. create the module
3. setup the navigation tree
4. create the templates for all level used
5. configure the module in the template
Templates:
- nav(x)_start.html
- nav(x)_on.html
- nav(x)_off.html
- nav(x)_stop.html
are used by default for each corresponding navigation-level (x)
Code: Alles auswählen
/**
* TT_Navigation v. 0.8 alpha
*
* INPUT
*
* @autor Christian Keller <kc@netspirit.ch>
* @copyright NETSPIRIT GmbH (CH) 2005 (http://www.netspirit.ch)
*/
include_once($cfg["path"]["contenido"] . 'includes/tt_navigation_include.php');
?>
<table cellspacing="0" cellpadding="0" cellpadding="4">
<tr>
<td class="text">acts in Category Layer:</td>
<td>
<select name="CMS_VAR[2]">
<option value="0" <? if("CMS_VALUE[2]" == 0) echo "selected";?> >-- off --</option>
<?php
if (!is_object($db2) ) {
$db2 = new DB_Contenido;
}
$sql = "SELECT max(level) as level FROM ".$cfg["tab"]["cat_tree"];
$db2->query($sql);
$db2->next_record();
$level = 1;
while ( $level <= $db2->f("level")) {
echo "<option value=\"$level\" ";
if("CMS_VALUE[2]" == $level) echo "selected";
echo " >-- $level --</option>";
$level++;
} ?>
</select>
</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td class="text">html template for layer start:</td>
<td><? echo make_select_dropdown_of_array ( get_template_list($cfg["path"]["frontend"] . "templates/"), "CMS_VAR[3]", 'CMS_VALUE[3]'); ?></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td class="text">html template for layer deselected:</td>
<td><? echo make_select_dropdown_of_array ( get_template_list($cfg["path"]["frontend"] . "templates/"), "CMS_VAR[0]", 'CMS_VALUE[0]'); ?></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td class="text">html template for layer selected:</td>
<td><? echo make_select_dropdown_of_array ( get_template_list($cfg["path"]["frontend"] . "templates/"), "CMS_VAR[1]", 'CMS_VALUE[1]'); ?></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td class="text">html template for layer end:</td>
<td><? echo make_select_dropdown_of_array ( get_template_list($cfg["path"]["frontend"] . "templates/"), "CMS_VAR[4]", 'CMS_VALUE[4]'); ?></td>
</tr>
</table>
<?php
Code: Alles auswählen
<?php
/**
* TT_Navigation v. 0.8 alpha
*
* OUTPUT
*
* @autor Christian Keller <kc@netspirit.ch>
* @copyright NETSPIRIT GmbH (CH) 2005 (http://www.netspirit.ch)
*/
// if the module is not set to off
if ( 'CMS_VALUE[2]' != 0 ) {
// get the nessesary functions
include_once($cfg["path"]["contenido"] . 'includes/tt_navigation_include.php');
// get the template class
include_once($cfg["path"]["contenido"] . 'classes/class.template.php');
// make a new instance
$tpl = new Template;
// if the db object ist not already an intance create one
if (!is_object($db2) ) {
$db2 = new DB_Contenido;
}
// sql to get the name and the id of the categories which are in the selected level:
// client id
// language
// visibility
// defined level
// only if they are in the subtree of the navigation
$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
A.level = 'CMS_VALUE[2]' AND
B.parentid = '" . is_in_tree ($idcat, $idcat, 'CMS_VALUE[2]') . "'
ORDER BY
A.idtree";
$db2->query($sql);
$tpl->reset();
$tpl->next();
// create the starting template
if ( 'CMS_VALUE[3]' == "" ) {
$tpl->generate('templates/nav' . 'CMS_VALUE[2]' . '_start.html');
} else {
$tpl->generate('templates/' . 'CMS_VALUE[3]');
}
// creating for each result the template
while ($db2->next_record()) {
$tpl->reset();
$tpl->set('d', 'NAME', $db2->f("name"));
$tpl->set('d', 'HREF', $sess->url('front_content.php?idcat='.$db2->f("idcat")));
$tpl->next();
// if it is in the active part use the on template otherwise the of
// or user defined templates
if (is_active($db2->f("idcat"), $idcat)) {
if ( 'CMS_VALUE[1]' == "" ) {
$tpl->generate('templates/nav' . 'CMS_VALUE[2]' . '_on.html');
} else {
$tpl->generate('templates/' . 'CMS_VALUE[1]');
}
} else {
if ( 'CMS_VALUE[0]' == "" ) {
$tpl->generate('templates/nav' . 'CMS_VALUE[2]' . '_off.html');
} else {
$tpl->generate('templates/' . 'CMS_VALUE[0]');
}
}
}
$tpl->reset();
$tpl->next();
// create the ending template
if ( 'CMS_VALUE[4]' == "" ) {
$tpl->generate('templates/nav' . 'CMS_VALUE[2]' . '_stop.html');
} else {
$tpl->generate('templates/' . 'CMS_VALUE[4]');
}
}
?>
Code: Alles auswählen
<?php
/**
* TT_Navigation_Include v. 0.8 alpha
*
* INPUT
*
* @autor Christian Keller <kc@netspirit.ch>
* @copyright NETSPIRIT GmbH (CH) 2005 (http://www.netspirit.ch)
*/
function is_active ($nav_cat_id, $tree_cat_id) {
global $client, $lang, $cfg;
if ($nav_cat_id <> $tree_cat_id) {
$is_active_first = 0;
if ( !is_object($db1) ) {
$db1 = new DB_Contenido;
}
$sql = "SELECT
B.parentid
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
A.idcat = $tree_cat_id";
$db1->query($sql);
$db1->next_record();
if ( $db1->f("parentid") <> 0) {
$is_active_first = is_active($nav_cat_id, $db1->f("parentid"));
}
return $is_active_first;
} else {
return 1;
}
}
function is_in_tree ($nav_cat_id, $tree_cat_id, $level) {
global $client, $lang, $cfg;
if ( !is_object($db1) ) {
$db1 = new DB_Contenido;
}
$sql = "SELECT
A.level,
B.parentid
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
A.idcat = $tree_cat_id";
$db1->query($sql);
$db1->next_record();
if ( $db1->f("level") == $level) {
return $db1->f("parentid");
} elseif ( $db1->f("parentid") <> 0 ) {
return is_in_tree ($nav_cat_id, $db1->f("parentid"), $level);
} else {
return $nav_cat_id;
}
}
function get_template_list($path) {
if (is_dir($path)) {
$resdir = opendir($path);
while ( $entry = readdir($resdir) ) {
if ( !is_dir($path."/".$entry) ) {
$ret[] = $entry;
}
}
closedir($resdir);
}
return $ret;
}
function make_select_dropdown_of_array ($array, $select_name, $select_value) {
$html = "<select name=\"" . $select_name . "\" size=\"1\" >\n";
$html .= "<option value=\"\"></option>\n";
foreach ($array as $value) {
if ( $select_value == $value) {
$html .= "<option value=\"" . $value . "\" selected>" . $value . "</option>\n";
} else {
$html .= "<option value=\"" . $value . "\">" . $value . "</option>\n";
}
}
$html .= "</select>\n";
return $html;
}
?>