tt_navigation multi-container-navigation

Gesperrt
netspirit
Beiträge: 5
Registriert: Di 26. Apr 2005, 16:44
Wohnort: Zürich
Kontaktdaten:

tt_navigation multi-container-navigation

Beitrag von netspirit »

hier mal zum Test freigegebene version 0.8 alpha, feedback ist erwünscht ;-)

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)
INPUT

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
OUTPUT

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]');
	}
}
?>
INCLUDE (tt_navigation_include.php)

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;
}

?>
Gruss Chris
HerrB
Beiträge: 6935
Registriert: Do 22. Mai 2003, 12:44
Wohnort: Berlin
Kontaktdaten:

Beitrag von HerrB »

This is a Multi -Layer-, -Language-, -Client-, -Container-, -Template-Navigation-Module for Contenido 4.5
Grundsätzlich schön, könntest Du noch beschreiben, was das ist/macht?

Gibt es einen Screenshot?

Gruß
HerrB
Bitte keine unaufgeforderten PMs oder E-Mails -> use da Forum!

Newsletter: V4.4.x | V4.6.0-15 (Module, Backend) | V4.6.22+
Standardartikelliste: V4.4.x | V4.6.x
http://www.contenido.org/forum/search.php | http://faq.contenido.org | http://www.communido.net
netspirit
Beiträge: 5
Registriert: Di 26. Apr 2005, 16:44
Wohnort: Zürich
Kontaktdaten:

Beitrag von netspirit »

Grundsätzlich ist es ein Navigations Modul, welches in verschiedenen Containern eingesetzt werdern kann und jeweils bei jedem der "level" konfiguriert werden kann... also z.B.:

1 / 2 / 3 / 4 in container 1 => level 1
1.1 / 1.2 / 1.3 / 1.4 in container 2 ( analog mit 2,3und 4) = level 2
1.1.1 / 1.1.2 / 1.1.3 .... in contaier 3 ...... = level 3

dabei sind die Levels unbeschränkt. Es werden default Templates benutzt wobei nicht "nur" das Eintrags-Template definiert werden kann, sondern auch der Start und Stop, somit kann zwischen vertikalen und horizontalen Designs frei gewählt werden. Im Input-Bereich kann aber auch die Defaulteinstellung überschrieben werden.



Bild
HerrB
Beiträge: 6935
Registriert: Do 22. Mai 2003, 12:44
Wohnort: Berlin
Kontaktdaten:

Beitrag von HerrB »

Ah, jetzt habe ich es verstanden.

Das verstehe ich noch nicht:
( analog mit 2,3und 4)
Und im Input findet sich

Code: Alles auswählen

<td><? echo make_select_dropdown_of_array ( get_template_list($cfg["path"]["frontend"] . "templates/"), "CMS_VAR[3]", 'CMS_VALUE[3]'); ?></td>
$cfg['path']['frontend'] ist der "reine" Serverpfad zum Root-Verzeichnis, z.B. bei

http://www.domain.tld -> /server/htdocs/html
http://www.domain.tld/cms -> /server/htdocs/html/cms

ist $cfg['path']['frontend'] = /server/htdocs/html. Ist es nicht eher $cfgClient[<Mandanten-ID>]["path"]["frontend"]?

Gruß
HerrB
Bitte keine unaufgeforderten PMs oder E-Mails -> use da Forum!

Newsletter: V4.4.x | V4.6.0-15 (Module, Backend) | V4.6.22+
Standardartikelliste: V4.4.x | V4.6.x
http://www.contenido.org/forum/search.php | http://faq.contenido.org | http://www.communido.net
holger
Beiträge: 1
Registriert: Sa 5. Okt 2002, 00:33
Kontaktdaten:

tt-Navigation

Beitrag von holger »

Hallo Chris,

ich habe deine Navigation ausprobiert, weil ich so etwas genau gesucht habe. Ist bestimmt eine tolle Sache. Leider bekomme ich im Frontend nichts angezeigt.

Ich schildere Mal kurz, was ich gemacht habe:

1. Modul erstellt und input und output eingetragen.
2. Die Änderungen von HerrB eingefügt, ansonsten bekam ich im Backend ne Menge Fehlermeldungen.
3.
nav1_start.html
nav1_on.html
nav1_off.html
nav1_stop.html

erstellt und folgend noch mit 2+3

4. In meinem Standardtemplate tt_navigation eingebunden und mit den Dateien verknüpft.

5. Die Datei tt_navigation_include.php erstellt und nach contenido/includes/ kopiert.

Ich bekomme nun im Frontend überhaupt nichts von einer Navigation angezeigt. Stelle ich bei meinem Standardtemplate wieder das Modul "Hauptnavigation" ein, ist meine Navigation wieder da.

Habe ich irgend etwas vergessen ?

mfg
Holger
Gesperrt