How to integrate the calendar in WordPress (Part 3)

It’s finally here… part 3. How to redirect the sidebar calendar clicks to a full page with the event details. In this part, we will be building on the previous two parts, so make sure to review those posts before continuing. You can use this setup if you prefer to redirect your users to a full page with event details instead of using the popup functions. The trick itself can be used in more than just WordPress, but this post will deal with the WP specific issues.

To start, we will deal with the easy part first. For this, we need to reuse the instructions from Part 2. You need to create a new page template, but this time instead of integrating the regular calendar, we’re going to add the 2nd part of the Blog mode. Don’t forget to change the name of the template in the code. Here, I am just adding the Blog list code as-is from the official docs for reference.

<?php
$EPCBLOG=2;
$template="blog.php";
$DF = "l, F j, Y"; 
require ("calendar/calendar.php"); 
?>

Then you will want to create a page that uses your new template. That will give you a URL… you want to make note of it, we’ll be using it later.

Now onto the guts of it… For this part, we need to go back to the sidebar. Here’s the gist of what we’ll be doing. First, we change the calendar mode to be the first part of the Blog mode. Then, we need to fake the calendar into thinking it’s somewhere else than it really is. And finally, we disable the default navigation and create our own.

To use the Blog mode, simply add $EPCBLOG=1; before the require. Then we set $thisFile to the URL we saved earlier, and set $noNav=1; to disable the default navigation. At this point the require is called, and right after we destroy the $thisFile variable. To create the replacement navigation, refer the post Create your own navigation table.

So here is the code that you would have in the sidebar, but note that I am omitting the navigation table code as it is a literal copy-paste of what is in the post mentioned just above. Of course, you would be setting $thisFile to your own URL.

$EPCBLOG=1;
$noNav=1;
$thisFile="/wordpress/calendar/blog-page/"; // use your own URL here
require("epcal/calendar.php");
unset($thisFile);
// add the navigation table code here

So there you have it. With this solution, a visitor can browse the calendar on the page they are currently viewing, and when they click on a date, it will direct them to a new page that has the event details.

This concludes the series, but look forward to new posts coming in the near future. Using widgets on your site? Stay tuned…

In case you missed the other posts in this series, please go to:

Tags: ,

Comments are closed.