The Mini Events Calendar

A great new modification to the Events Calendar plugin for wordpress. It is work in progress so all comments and any further mods are welcome. I’ll be working on this more and more over coming weeks.

This is a modification to The Events Calendar plugin created by Shane & Peter, Inc. Version 1.6.4 | Visit plugin site for further details and make sure you give them a donation.

The Mini Events Calendar plugin is great for displaying events on your site. It has bags of features and is really customisable. The only snag is it doesn’t come with a mini calendar. At first I thought I could just alter the CSS to style the calendar differently, however with styling to a smaller size came the need for different functionality than the default settings. I needed to be able to click on the day and display all of the events of that day on a separate page. I didn’t want tool tips to appear on the calendar as they got in the way but rather the whole day highlight to show that that day had events. Also I didn’t want the title of each event to show up within the calendar.

mini calendar

I have created the mini calendar from the existing files that come with the plugin and saved the scripts as wordpress templates rather than edit the plugin files. This way, you still get the funcionality of an unaltered plugin but with the added extra mini calendar. Hopefully this should cut down (probably not all togther!) on anything that may go amiss if the original plugin get’s updated. I’m afraid this isn’t compatible as a widget and doesn’t use the original WordPress calendar.

Ok so if you are interested in having a go with this mod then download the files and follow below.

As these files are reconstructed from original plugin scripts, it may mean that some code might be better scripted. I can see already that there is a small clash with the_title and the_content. But these are easily remidied. I just don’t have the time at the moment to really pick through it, and will return to it when I next get chance – so don’t shoot me down because of some areas of poor coding. However if you can script any aspect of it better, then by all means contribute and post your work. All comments welcome. Oh and this uses pretty permalinks and you may run into problems if you don’t use them.

Ok let’s get started:

I’m going to make this as simple as possible as there is a lot of script and trying to explain any of it would take forever so it’s a basic copy and paste job and copying some files over.

1.Download and install the plugin (current version 1.6.4).

2. Download the zipped up files here and uncompress.

3.Create a folder in the root of your theme folder and call it events.

4. Add all of the files apart from style.css to the events folder and upload.

5. We now need to create a template to display the mini calendar so duplicate your page.php file from the root of your theme folder and call it page-mini-calendar.php.

6. Open page-mini-calendar.php and at the top of the file add this code:

*/ require_once('events/miniCal1.php');?>

7. Then add this code to the same page-mini-calendar.php anywhere in the document that you want the calendar to display:

 

8. Upload page-mini-calendar.php to your theme folder

9. We now need to create a template to display the listings if someone clicks on a highlighted day in the calendar – so duplicate your page.php file from the root of your theme folder and call it page-day-list.php.

10. Open the newly created page-day-list.php and at the top of the file add this code:

*/ require_once('events/list1.php');?>

11. Then add this code to the same page-day-list.php anywhere in the document that you want the listings to display:

 

12 Upload page-day-list.php to your theme folder

13 Login to your admin and create a new page and call it something like minicalendar. I have nice permalinks turned on so my url will be http://www.chriscannon.co.uk/minicalendar/ and you should have something similar otherwise you may hit snags with the code.

14. Set the template to mini-calendar from the template drop down and save the page.

15 Create a new page in your admin and call it listings. Set this template to day-list from the template drop down. Again the permalink to my url will be http://www.chriscannon.co.uk/listings/ and you should end in /listings. If you really didn’t want to call it listings you will need to alter the line:

$return .= "/listings?id=$day-$month-$year";

in your miniCal1.php and change that from /listings? to /somethingelse?

16. You should now have an unstyled calendar. I have also inclueded a basic set of css styles in style.css. They aren’t spectacular but paste them into your normal stylesheet for the site and alter to your needs.

Let me know what you think. As I said there does seem to be a snag with the_title and the_content for the calendar page. It seems to get replaced with the details of your first event that you input. I got round this on the calendar page by storing the content in variables near the top of the miniCal1.php and then using them further down where I needed them.

$calendarHeader = the_title("","", false);
$calendarContent = the_content("","", false);

I’ll try and have a go further with these files as I think there is also a bit of unnecessary php scripting which could be removed.

This entry was posted in developments, Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post. Post a comment or leave a trackback: Trackback URL.

16 Comments

  1. Alan
    Posted February 18, 2011 at 3:22 pm | Permalink

    Yes got it working!

  2. rz
    Posted February 22, 2011 at 10:24 am | Permalink

    Sorry I’m not clear on this step – “Then add this code to the same page-mini-calendar.php anywhere in the document that you want the calendar to display”. What is the document referred to? Say if I want to put the mini calendar in the sidebar, what should I do? Thks

    • cannon303
      Posted February 22, 2011 at 4:02 pm | Permalink

      Hi rz, I think you are referring to point 7. page-mini-calendar.php is the template page you created in point 5 by duplicating your page.php from you theme folder and the code that you add:

      require_once(‘events/miniCal2.php’);

      refers to miniCal2.php that you should have downloaded from the start of this page. If you wanted to add that line to your side bar then I would suggest you duplicate your sidebar.php and call it sidebar-miniCal.php. Open sidebar-miniCal.php and paste:

      require_once(‘events/miniCal2.php’);

      in to that document wherever you wanted the calendar to display and upload it. Then in page-mini-calendar.php look for:

      get_sidebar();

      and change it to:

      get_sidebar(‘miniCal’);

      and that should put it in the side bar

  3. Kriggity
    Posted March 19, 2011 at 2:42 am | Permalink

    Should the template name at the top of page-day-list.php be something other than ‘mini-calendar’? If I’m assigning a template to a page on Edit Page, how does the admin know which file to use if ‘mini-calendar’ is the template name for both page-mini-calendar.php and page-day-list.php?

    • Chris
      Posted March 19, 2011 at 10:06 am | Permalink

      Hi Kriggity yes you’ve spotted an error there on step 10. I’ll change it. It should read:

      10. Open the newly created page-day-list.php and at the top of the file add this code:

      <?php /* Template Name: day-list
      */ require_once('events/list1.php');?>

      and point 15 should read:

      15 Create a new page in your admin and call it listings. Set this template to day-list from the template drop down…..

  4. Kriggity
    Posted March 25, 2011 at 4:56 pm | Permalink

    Chris,
    I changed this line of code as instructed in step #15:
    $return .= "/listings?id=$day-$month-$year";
    I’m now using get_Permalink();. This correctly links to the proper posts, but now my events are showing up in the wrong days in the mini-calendar.
    Any idea why this might be happening? Is it breaking in the query or possibly elsewhere?

    • cannon303
      Posted March 26, 2011 at 12:42 am | Permalink

      Hi Kriggity. I don’t think get_Permalink(); will work as (although I’ve not tried it) I think it will cause the events to show up on the date they were created rather than the date of the event. I would keep your scripting as:
      $return .= "/listings?id=$day-$month-$year";

      just to get it working. If you are stuck, post your url, i might be able to see what is going wrong.

      • Kriggity
        Posted March 27, 2011 at 5:08 pm | Permalink

        You’re correct, Chris. I found that using get_Permalink(); uses the date the post was created rather than the event date.

        Also, I modified miniCal2.php so that the “View Calendar” link under the calendar grid links to its respective month. For example, I have the mini-calendar in the sidebar of my homepage. If I use the double arrows (>>) to go forward or back to a different month, “View Calendar” will link to its respective month rather than linking to “…events/upcoming/”.

        Anyway, I changed this code:
        <a class="viewCal" href="/category/events/upcoming/">View Calendar

        to this:

        <a class="viewCal" href="/category/events/month">View Calendar

        <a class="viewCal" href="/category/events/-">View Calendar

        I’ve found this works with the following permalink structures:

        /%category%/%postname%/
        /%year%/%monthnum%/%postname%/

        but it does not appear to work if the permalink structure is set to “default”.

        Cheers,
        Krig

        • Kriggity
          Posted March 27, 2011 at 5:19 pm | Permalink

          Comment post fail. Let’s try posting that code again.

          Changed this:
          <a class="viewCal" href="/category/events/upcoming/">View Calendar

          To this:
          <?php
          vif (!$theYear && !$theMonth) {
          ?>
          <a class="viewCal" href="/category/events/month">View Calendar
          <?php
          } else {
          ?>
          <a class="viewCal" href="/category/events/-">View Calendar
          <?php
          }
          ;
          ?>

          • Kriggity
            Posted March 27, 2011 at 5:25 pm | Permalink

            Third time’s a charm?

            This:
            <...a class='viewCal' href='/category/events/upcoming/'>View Calendar

            To This:
            <?php
            if (!$theYear && !$theMonth) {
            ?>
            <...a class='viewCal' href='/category/events/month'>View Calendar
            <?php
            } else {
            ?>
            <...a class='viewCal' href='/category/events/-'>View Calendar
            <?php
            }
            ;
            ?>

            Obviously the “…” don’t belong there. Am just trying to trick the comment thing from processing the “a” tags.

        • Kriggity
          Posted March 27, 2011 at 6:07 pm | Permalink

          I give up. Just check out this page for the code:
          http://kriggity.com/miniCal2.html

          • cannon303
            Posted March 27, 2011 at 6:47 pm | Permalink

            Yep must have something wrong with my comment settings, but thanks for the tip with the view calendar. I’ll add it to the files. Does this mean you’ve got it working?

          • Kriggity
            Posted March 28, 2011 at 1:28 am | Permalink

            Yes, it seems to be working fine as long as the permalink structure isn’t set to default. I’m sure that with some more attention this change could be made more bulletproof.

            I’ll post a link as soon as I move my project to the live interwebs.

            Feel free to delete my failed comment posts.

  5. cannon303
    Posted March 26, 2011 at 12:54 am | Permalink

    Here’s a link to a website with the mini calendar working:
    http://barton-upon-humber.org.uk/

    I have also got some other tweaks to stop events mixing with normal posts during the default wordpress display of posts which is a problem that stems from the default installation of the events calendar and I would have thought the makers of the plugin will address this issue but in the meantime I’ll post them in a day or two.

  6. caitlin downs
    Posted February 28, 2015 at 10:37 pm | Permalink

    Hi,

    Just a query – is this still up to date? When we tried to install it, it threw up a function error? Any suggestions or alterations you have made to your own copy?
    Thanks ^.^

    • cannon303
      Posted March 30, 2015 at 12:51 am | Permalink

      Hi it is still up to date I think as I updated the plugin and wordpress to the latest versions and it still works.

Post a Reply to Kriggity

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>