The plugin i18n additionally provides a hierarchical multi-language aware navigation menu and breadcrumbs. But you don't need to have a multi-language website to use this simple navigation.
The plugin enhances the user interface for defining a page's position in a multi-level menu tree, e.g.
Download the plugin from http://get-simple.info/extend/plugin/i18n/69/, unzip it and copy it to the plugins directory of your GetSimple installation.
Set the page's parent and order in the menu on the page edit view or use the Pages/Edit Navigation Structure view in your GetSimple administration.
Insert the following fragment into your template(s):
<?php get_i18n_navigation(return_page_slug(), minlevel, maxlevel, show); ?>
where minlevel and maxlevel define which levels of the navigation should be displayed. Level 0 is the top-most level, i.e. all pages with no parent page. show can be one of the following constants:
- I18N_SHOW_NORMAL: the minlevel level of the menu is shown and all higher levels if they are necessary to show the current page as well as all children of the current page
- I18N_SHOW_MENU: all levels of the menu from minlevel to maxlevel are shown independent of the current page (for use with dropdown menus)
- I18N_SHOW_PAGES: like I18N_SHOW_MENU, but all pages not in the menu are shown, too (for use as site map)
- I18N_SHOW_TITLES: like I18N_SHOW_PAGES, but the page titles are shown, even if menu texts are specified (for use as site map)
- I18N_SHOW_LANGUAGE: like I18N_SHOW_NORMAL, but only menu items are shown that exist in the current language.
For a simple menu bar (top-most level only), use:
<?php get_i18n_navigation(return_page_slug()); ?>
To display the remaining levels in the side bar, use:
<?php get_i18n_navigation(return_page_slug(),1,99); ?>
To display only those menu entries that are available in the current language, use:
<?php get_i18n_navigation(return_page_slug(),1,99,I18N_SHOW_LANGUAGE); ?>
Do display breadcrumbs, put something like the following into your template:
<div class="breadcrumbs"> <a href="<?php echo find_url('index',null); ?>">home</a> <?php get_i18n_breadcrumbs(return_page_slug()); ?> </div>
To display a site map with all pages:
<?php get_i18n_navigation('index',0,99,I18N_SHOW_PAGES); ?>
If you want to only display the pages that are shown in the menu, use I18N_SHOW_MENU as 4th parameter. You can put this code in a component and include it in your page with the DynPages plugin.
Please see also the following examples:
- Menu on the left side
- Top menu bar (level 0) and remaining levels on left side
- Top menu bar (level 0) and remaining levels on left side (all open)
- Top menu bar with pulldown menus (levels 0 and 1) and menu on left side starting with level 1
To add internal or external links in your navigation menu, do the following:
- Install the I18N Custom Fields plugin.
- Goto Plugins/Configure Custom Fields in your GetSimple administration and create a field of type link with name link.
- For each link create an empty page with a title and Add-to-menu = yes and enter an external link into the field link (or select an internal page using the browse functionality).
- Make sure these empty pages have the correct parent and position in the navigation structure.
returns an associative array of pages with the attributes url (slug), menuData, menuOrder, title, menu, parent (the parent's url/slug) and the other languages' titles and menus (as e.g. title_en, menu_en). Additionally a sorted array of the children urls/slugs is available in the attribute children. The page with url/slug null contains the toplevel pages in the children array.
return_i18n_structure($slug=null, $menuOnly=true, $slugToIgnore=null)
returns the structure of the site in a flat sorted array where each entry is an associative array with the attributes url (slug), menuStatus, title, menu and level. If $slug is given, only the children (and their children, ...) of this page are returned. $menuOnly = false returns all pages, even if they are not in the menu. If $slugToIgnore is given, this page and all its children (...) are ignored.
return_i18n_menu_data($slug, $minlevel=0, $maxlevel=0, $show=I18N_SHOW_NORMAL)
returns the menu tree from level $minlevel to $maxlevel, where the children of the $slug and of all (recursive) parents of the $slug are shown, if permitted by level and the menuStatus attribute of the child. A parent with menuStatus = N is not shown and neither are its children. With $show =
- I18N_SHOW_MENU all sub menus are shown independent of the current page,
- I18N_SHOW_PAGES and I18N_SHOW_TITLES show all pages whether they are in the menu or not (the latter shows titles instead of menu texts) and
- I18N_SHOW_LANGUAGE is like I18N_SHOW_NORMAL, but only shows pages in the current language. A tree node has the attributes parent, url (slug, String), title, menu (localized strings), children (array), current (true, if current page) and currentpath (true, if in path to current page).
(3.0+) The parameter $show can be defined as a combination of the following constants (e.g. instead of I18N_SHOW_NORMAL you can use I18N_FILTER_MENU | I18N_FILTER_CURRENT | I18N_OUTPUT_MENU) (do NOT use these constants together with the I18N_SHOW_* constants)
- I18N_FILTER_NONE - no filter (private pages are always filtered)
- I18N_FILTER_CURRENT - show children of given page and all siblings and parents/siblings
- I18N_FILTER_LANGUAGE - show only pages in current language
- I18N_FILTER_MENU - show only menu pages
- I18N_OUTPUT_MENU - output menu title
- I18N_OUTPUT_TITLE - output page title
returns an array with breadcrumbs, each with attributes url, parent, menu, title.
get_i18n_navigation($slug, $minlevel=0, $maxlevel=0, $show=I18N_SHOW_NORMAL)
outputs the (localized) menu for the $slug (the menu tree returned by return_i18n_menu_data, same parameters).
(3.0+) get_i18n_navigation($slug, $minlevel=0, $maxlevel=0, $show=I18N_SHOW_NORMAL, $component=null)- you can specify a $component by name to do the rendering.
outputs the breadcrumbs each as " » <span class="breadcrumb"><a ...</a></span>"
outputs a link to the given $slug with the title in the current language as text.