Structure

Template structure and navigation


Idea

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.

Frameworks and scripts

This demo website is based upon the Boostrap CSS framework and makes use of the bootstrap related Font Awesome icon set.

Moreover, the site works with jQuery and several jQuery plugins like PrettyPhoto (lightbox gallery), Flexslider (home slider) or Prettify (code formatter).

Find some details on the REDAXO addons included within this demo.

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

Categories and articles

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.

Navigation

A navigation will usually be built from the categories of a website. REDAXO provides several ways to implement it. You can use the class “rex_navigation” to generate common navigations, even with minimal PHP knowledge.

This is what a simple navigation may look like:

<?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

REDAXO CMS is designed to be highly customizable and to control the output in all details. It’s more like a CMS framework, and it perfectly fits with the requirements of web companies developing various websites.

REDAXO 5 rocks!