deutsch english
mvlcek online
software & more...
  • Dive Expeditions
    • Cayman Islands March 24, 2012 - April 1, 2012
    • Honduras November 4, 2011 - November 12, 2011
  • Destinations
    • Cayman Islands
    • Honduras
    • Galapagos
    • Maldives
  • Liveaboards
    • Aggressor Fleet
    • Buddy Dive Liveaboard
    • Explorer Ventures
  • Fish Tales
    • Honduras by Tammy
    • Maldives by Richard, Jo, Jim, Petra
home » getsimple » navigation » navigation demo

Navigation Demo

This is a demo showing various navigational case studies.

Referencing other pages

In our example we have destinations, like 'Honduras', and we have other pages, like fish tales, that describe something taking place at these destinations.

If a destination is shown, we want to show everything taking place at this destination, and when a page is shown, which takes places at any destination(s), we want to show these destinations.

To describe where a page's content takes place, we just tag the page (in Tags/Keywords) with a tag '_dest_' + destination slug, e.g. with '_dest_honduras' (without quotes), if it takes place in Honduras (the page having slug honduras).

We organize the pages in a hierarchical structure:

  • Destinations (slug destinations)
    • Honduras (slug honduras)
    • Maledives (slug maledives)
    • ...
  • Liveaboards (slug liveaboards)
    • Aggressor Fleet (tagged with _dest_maledives, _dest_honduras, ...)
    • Explorer Ventures (tagged with _dest_maledives, ...)
    • ...
  • Dive Expeditions (slug expeditions)
    • ...
  • Fish Tales (slug tales)
    • ...

We also need to install the I18N Plugin.

Showing a filtered menu

To show a side bar menu with all Liveaboards, Dive Expeditions and Fish Tales, we create a component filtered-by-destination:

<?php
  global $args;
  // the parent page for the items to display, e.g. 'expeditions'
  $parent = $args[0];
  // the current page, which should be a destination
  $slug = (string) return_page_slug();
  // the cached page information
  $pages = return_i18n_pages(); 
  $filtered = array();
  // the array with all items below the parent
  $entries = return_i18n_menu_data($parent, 1, 1, I18N_SHOW_NORMAL);
  foreach ($entries as $entry) {
    $url = $entry['url'];
    // split the tags/keywords (string) into an array
    $tags = preg_split('/\s*,\s*/',$pages[$url]['tags']);
    // only items in the current destination are used
    if (in_array('_dest_'.$slug, $tags)) $filtered[] = $entry;
  }
  // display all filtered items, if there are any
  if (count($filtered) > 0) {
    echo '<h3>'.$pages[$parent]['title'].'</h3>';
    echo '<ul class="menu">';
    foreach ($filtered as $entry) {
      echo '<li><a href="'.find_i18n_url($entry['url'],$parent).'">'.$entry['title'].'</a></li>';
    }
    echo '</ul>';
  }
?>

and call it in the template with

  get_i18n_component('filtered-by-destination','liveaboards');
  get_i18n_component('filtered-by-destination','expeditions');
  get_i18n_component('filtered-by-destination','tales');

Showing all referenced pages

To show all pages that the current page references via the tags like _dest_honduras, we create another component destinations:

<?php
  $slug = (string) return_page_slug();
  // the cached page information
  $pages = return_i18n_pages();
  echo '<h3>Destinations</h3>';
  echo '<ul class="menu">';
  // split the tags/keywords (string) into an array
  $tags = preg_split('/\s*,\s*/',$pages[$slug]['tags']);
  foreach ($tags as $tag) {
    // show the pages denoted by destination tags
    if (substr($tag,0,6) == '_dest_') {
      $url = substr($tag,6);
      echo '<li><a href="'.find_i18n_url($url,$pages[$url]['parent']).'">'.$pages[$url]['title'].'</a></li>';
    }
  }
  echo '</ul>';
?>

and call it in the template with

get_i18n_component('destinations');

Putting all together

To create the effect as shown in this demo, we put the following code into the template:

<?php
$slug = (string) return_page_slug();
$parent = (string) get_parent(false);
$pages = return_i18n_pages();
if ($slug == 'destinations' || $slug == 'liveaboards' || $slug == 'expeditions') {
  echo '<h3>'.get_page_title(false).'</h3>';
  echo '<ul class="menu">';
  get_i18n_navigation($slug, 1, 1, I18N_SHOW_NORMAL);
  echo '</ul>';
} else if ($parent == 'destinations') {
  echo '<h3>Destination</h3>';
  echo '<ul class="menu"><li class="current"><a href="'.get_i18n_page_url(true).'">'.get_page_title(false).'</a></li></ul>';
  get_i18n_component('filtered-by-destination','liveaboards');
  get_i18n_component('filtered-by-destination','expeditions');
  get_i18n_component('filtered-by-destination','tales');
} else if ($parent == 'liveaboards' || $parent == 'expeditions' || $parent == 'tales') {
  get_i18n_component('destinations');
  echo '<h3>'.$pages[$parent]['title'].'</h3>';
  echo '<ul class="menu">';
  get_i18n_navigation($slug, 1, 1, I18N_SHOW_NORMAL);
  echo '</ul>';
}
?>

The functions used are either GetSimple functions documented in the [url=http://get-simple.info/wiki/themes:template_tags]Wiki[/url] or I18N plugin functions documented in i18n_base.php or i18n_navigation.php.

© 2025 mvlcek online
Powered by GetSimple