Create your own navigation table

This is one of the recurring topics on the forum: “How do I modify/move the navigation table”. The answer is almost always either a reference to another post, or bits of code strewn about a few posts. This will become the reference on how to create your own navigation table with the whole code explained and in one spot. It will cover situations like these, and more :

  • Putting the table above the calendar, instead of below
  • Adding navigation to the List mode (when not using another mode)
  • Changing the number of months jumped when using the Multi-Calendar Generator

If you are using either the regular mode, or the Multi-Calendar Generator plugin, you see that you already have a navigation table. So the first thing we want to do is stop that one from showing up. You have two options for disabling it.

The first one is through the Setup Manager, under the Navigation section. Simply set the “Show Navigation Table:” to “No”. The downside to this way is that it disables the navigation table everywhere. This is not viable if you have calendars on other pages. We need a more flexible option.

The answer to that one is to use one of the command line variables. The aptly named “$noNav”. Simply add that variable above the require() that shows the calendar (or multi-calendar). If you have other calendars on the rest of the page where you want the navigation table to show up, use unset() to destroy the variable $noNav. Here’s the code that shows how it would look.

// You can remove the following line if you have no other calendars on your page

So now, we’ve disabled the table we didn’t want, here’s how we add our own. First, we’ll need to initialize some variables. What the code does is checks if the $mo and $yr variables had been set already, and then assigns the values for the ‘back’ and ‘forward’ arrows.

Most people using the Multi-Calendar Generator plugin that want to modify the navigation, want to move month by month, but should you want to tweak how many months before and after you jump to, change the value on the lines as indicated.

The last bit of the code is there to handle if you are passing other arguments in your URL

// check for $mo and $yr from the URL

// setting the variables for the table
$mb=$mo-1; // <-- change this one for month before, don't exceed 12
if ($mb<1) {$mb+=12; $yb=$yr-1;}
$mf=$mo+1; // <-- change this one for month after, don't exceed 12 if ($mf>12) {$mf-=12; $yf=$yr+1;}

$cmo = date("m");
$cyr = date("Y");

// check to make sure not to wipe other arguments
$returnString = "";
$queryString = explode("&",$_SERVER['QUERY_STRING']);
for ($i=0;$i<count($queryString);$i++) { $v = explode("=",$queryString[$i]); if (($v[0] != "mo") && ($v[0] != "yr")) { $returnString .= (($returnString=="") ? ($queryString[$i]) : ("&".$queryString[$i])); } } } ?>

This next section can be put directly after the section we just passed, or can be separated if you want to keep your code clean. This is what actually creates the table. It takes all the values that were set before it and generates your navigation table.

<table class="navTable" cellspacing="0" cellpadding="0">


<td align="left" width="33%"><a href="<?php echo "$thisFile?".$returnString.($returnString==""?"":"&")."mo=$mb&yr=$yb$anchorTag".$returnString2; ?>" class="navTableText"><?php echo $navLeft; ?></a></td>

<td align="center" width="34%"><a href="<?php echo "$thisFile?".$returnString.($returnString==""?"":"&")."mo=$cmo&yr=$cyr$anchorTag".$returnString2; ?>" class="navTableText"><?php echo $navMiddle ?></a></td>

<td align="right" width="33%"><a href="<?php echo "$thisFile?".$returnString.($returnString==""?"":"&")."mo=$mf&yr=$yf$anchorTag".$returnString2; ?>" class="navTableText"><?php echo $navRight; ?></a></td>



I think everything has been covered. Should you find anything that doesn’t work as expected, please either leave a comment, contact me using the link at the top, or post in the forums.


2 Responses to “Create your own navigation table”

  1. Hi Brian,
    I am a bit confused. Where is the code listed above? All the files that I have are encoded. I have bought a license but not put it in place because I don’t want to use the license on my dev environment. Another question is, do I need to get another license for my dev site (not localhost).

    Comment by JamieJanuary 19th, 2010 @ 5:57 am

  2. This is not Brian. He has nothing to do with this website.

    The code that is included in this post is all code that you will add to the page where you’re integrating the calendar. Simply read the post thoroughly and it is very clearly explained.

    As for your license questions, this is not the right place to ask. I am not affiliated with EPC in any manner. Refer to them for support.

    Comment by ve9graJanuary 19th, 2010 @ 7:33 am