How to create module navigation

A common and useful slot that is normally present in every page of a module is the module index that allows navigation within the module. This slot is usually called index.php. For example for the core module it will be stored in common/pages/core/index.php, common/templates/core/index.tpl and common/navxml/core.xml

Here is what core/index.php looks like.

    
require_once "common/classes/obliquid/nav.php";

/** access structure for core module */
function core_index_()
{
    global $_obweb;

    $nav = & new nav();
    $corelinks = $nav->getNav("core");    //Get the array for the icons

    //Now assign them for the template, and we are done
    $_obweb->smslot->assign("corelinks", $corelinks);
}

  

And here is what index.tpl looks like.

    
{{* $Id: common_mod.xml,v 1.5 2004/02/11 00:38:31 vrtisworks Exp $ *}}
<table width="160">
{{foreach from=$corelinks item=alink}}
<tr><td>
{{if $alink[2] eq "*none*"}}
<a href="{{$alink[0]}}" class="textmini">{{$alink[1]}}</a>
{{else}}
<a href="{{$alink[0]}}" class="textmini">
<img src="{{$alink[2]}}" width="16" height="16" border="0">&nbsp;{{$alink[1]}}</a>
{{/if}}
</td></tr>
{{/foreach}}
</table>

  

And finally, here is what core.xml looks like. For details about the format and information in a navxml file, please see the section on "Site Naviation".

    
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: common_mod.xml,v 1.5 2004/02/11 00:38:31 vrtisworks Exp $ -->
<NAVOBJECTS>
 <NAV PAGE="core_confpagegroup" ORD="10">
  <THEME NAME="*default*">
   <TEXT>List modules and their pages</TEXT>
  </THEME>
 </NAV>
 <NAV PAGE="core_configparms" ORD="20">
  <THEME NAME="*default*">
   <TEXT>Configure parameters</TEXT>
  </THEME>
 </NAV>
 <NAV PAGE="core_cron" ORD="25">
  <THEME NAME="*default*">
   <TEXT>Scheduled jobs</TEXT>
  </THEME>
 </NAV>
 <NAV PAGE="core_admtheme" ORD="30">
  <THEME NAME="*default*">
   <TEXT>Manage themes</TEXT>
  </THEME>
 </NAV>
 <NAV PAGE="core_conflang" ORD="40">
  <THEME NAME="*default*">
   <TEXT>Configure languages</TEXT>
  </THEME>
 </NAV>
 <NAV PAGE="core_resethas" ORD="45">
  <THEME NAME="*default*">
   <TEXT>Reload your security</TEXT>
  </THEME>
 </NAV>
 <NAV PAGE="core_demodata" ORD="50">
  <THEME NAME="*default*">
   <TEXT>Load demo data</TEXT>
  </THEME>
 </NAV>
</NAVOBJECTS>

  

To make this slot appear we will need to insert the permission to see the slot in the security table.

INSERT INTO {{$tprefix}}security VALUES (141,'core/index::','g1','s')
INSERT INTO {{$tprefix}}security VALUES (142,'core/index::','g2','s')

Further, we will need a navigation permission for every link in this slot. In this way we are able to deliver a different set of links for each group.

INSERT INTO {{$tprefix}}security VALUES (143,':core_mypage:','g2','n')