Search

After having to revisit a calendar of events and kind of hacking my way through it originally, I've come up with another way to incorporate an event calendar more easily into an existing site. A very simple example is hosted here. The source is available at github. If you have any issues, please discuss them here.

Requirements:

  1. Nils' Date and Time Field Extension - Because it uses a nice interface and allows for easier management of events; make sure to take the experimental branch.
  2. This event I created, found on github, placed in your workspace/events folder.
  3. A section to handle all the events with a single Date & Time field, it must contain at least one other field, like name, description, etc. But you can have as many as you like. They will all be displayed, and can be disabled by using CSS display:none; on the <li>. For example, if we had a field called description it would be produced as <li class="description">, so .description { display: none; } would get rid of it.
  4. Attach the event to whatever page you want to display the calendar on.
  5. Attach a data-source pulling whatever events you wish, you can limit it by date to reduce the amount of entries, but do not change the grouping.
  6. Finally, in the page you wish to drop the calendar in, the php xmlns must be added to the <stylesheet> tag, and the function to generate the calendar must be used. An example page would look like is below. The second parameter next to the function is the name of the data source. The third is an optional path to link to the event by id so you provide the root path (if none is provided it will just be listed as text). The fourth is an optional class to provide the table with, the default is calendar.

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            xmlns:php="http://php.net/xsl">
    
    <xsl:import href="../utilities/master.xsl"/>
    
    <xsl:template match="/data">
    
    <h1><xsl:value-of select="$page-title"/></h1>
    <xsl:value-of select="php:function('generate_calendar', calendar-main-events, concat($root,'/calendar/event'), 'calendar')" disable-output-escaping="yes"/><br />
    </xsl:template>
    </xsl:stylesheet>
    

Bugs/features:

  1. It's not possible to have a date field in the same section you plan to use for the events, it conflicts with a date time field.
  2. If you have two calendars on the same page, when you switch months/years, it will switch them on both calendars.

The link to the event is dead... Plus have you got an example of this in action? Very intruiging, especially the php:function stuff...

Urgh... Me no likey php:function.

After reading, don't these have to be exclusively enabled in PHP first?

@designermonkey, I updated the link. I'll have an example in a couple days hopefully. And the event enables PHP, you don't have to do anything else.

@phoque, I don't really like using PHP either, it's a little awkward, but I had so much trouble dealing with more complex logic in XSLT, it just makes more sense to use straight PHP. The only thing I'm worried about is how the performance would compare, I suspect straight PHP would be a little faster, but we'll see!

I'm sure that when we can see it all in action, we'll all be able to find a way of avoiding the PHP ;o)

Looking forward to it!

I've put an example up here for you guys to check out. It's a simple example, and you must forgive the poor styling! You can find the the source of it @ github.

Sooper cool!

@scottkf - it is possible to implement this calendar using ajax, because for every month or year ,the page is getting post back , any tips how to convert this ?

Within the context of my example something like the following should work:

$('.calendar th a').click(function (e) {
    e.preventDefault();
    $.get($(this).attr('href'), function(data) {
        $('body').empty();
        $('body').append(data);
    }); 
});

It reloads the entire page, but you could streamline it.

how to achieve these things

i want to highlight the date (if their is an event associated with that date it should be highlighted)

i want to display all the event associated on a particular date(as of now you used event-id to filter the events i want to display the events based on the date it is associated not with the event-id as filter field)

how to achieve the above mentioned functionalities - any guidance/ help will be more useful,

thanks

i want to display all the event associated on a particular date(as of now you used event-id to filter the events i want to display the events based on the date it is associated not with the event-id as filter field)

  • any help or guidance ?

any help or guidance ?

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details