When developing websites, there’s usually more than one final solution. You may choose from several ways to set up the structure, the templates and the modules for your website. Oftentimes, it all depends on the context.
As a result, working with REDAXO is sometimes not obvious for beginners. And due to the fact that a proper structure may vary between websites, it’s all but impossible to write a common user manual.
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.
REDAXO uses categories and articles. Think of articles as pieces of paper containing content like texts, images, videos et al.
Categories represent the navigation structure. Any category includes at least one article—which is the start article. Think of categories as a folder containing papers. Summary: articles represent content, while categories build up the site hierarchy.
<?php
$nav = rex_navigation::factory();
echo '<div id="navigation">';
echo $nav->get(0,2,TRUE,TRUE);
echo '</div>';
?>
This snippet defines the navigation output
$nav->get(0,-1,FALSE,TRUE);
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>';
?>