News and Events

Template structure and navigation


Please do not consider this demo site as a standard how to work with REDAXO. It’s supposed to demonstrate just ONE possible solution, containing very personal opinions on developing websites.


The REDAXO team

<?php 
$nav = rex_navigation::factory();

echo '<div id="navigation">';
echo $nav->get(0,2,TRUE,TRUE);
echo '</div>';
?>

On rex_navigation

This snippet defines the navigation output
$nav->get(0,-1,FALSE,TRUE);

  • The first parameter—here: “0”—defines where to start the navigation. “0” means to start at the top level.
  • The second parameter specifies the number of levels: “-1” means to consider all levels. You may insert a specific value instead. Common values are 2 or 3.
  • Use the third parameter to control whether to show all categories or the active ones only. Set to “FALSE” in order to generate a sort of sitemap, or use “TRUE” for a default navigation where only the sub-categories of the current category will be visible.
  • The fourth parameter defines whether to show online articles only (“TRUE”) or offline articles, too (“FALSE”).

Custom navigation

Despite rex_navigation being suitable for a lot of use cases, you’ll sometimes need to develop custom navigations. Starting with the “path” value of any article, which is like a breadcrumb path and contains information where to find the article, it needs little PHP knowledge only to build a custom navigation.

This is what code looks like for the navigation of this demo site. It shows one level only to keep the example straightforward. You can find the complete code for both the two levels in the template “05 . Navigation”.

<?php
$path = explode("|",$this->getValue("path").$this->getValue("article_id")."|");
$path1 = ((!empty($path[1])) ? $path[1] : '');

echo '<ul>';

foreach (rex_category::getRootCategories() as $lev1) {

if ($lev1->isOnline(true)) {

if ($lev1->getId() == $path1) {
echo '<li class="active"><a href="'.$lev1->getUrl().'">'.htmlspecialchars($lev1->getValue('name')).'</a></li>';
} else {
echo '<li><a href="'.$lev1->getUrl().'">'.htmlspecialchars($lev1->getValue('name')).'</a></li>';
}

}
}

echo '<ul>';
?>

REDAXO CMS

Postal address
Stadtarchiv Dessau-Roßlau
Heidestraße 21
06842 Dessau

E-Mail
stadtarchiv@dessau-rosslau.de

Phone and Fax
Tel: +49 (0) 340 204 10 24
Fax: +49 (0) 340 204 24 24

Social links

REDAXO 5 rocks!