Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2017-07-18 09:58:03

CodeWalker
Member
From: Hampshire, UK
Registered: 2010-01-08
Posts: 110
Website

smd_calendar advice

Hello everyone.

I want to use smd_calendar to display articles from database AND pull in event data from a Google Calendar so the two data streams are merged into one calendar. I understand smd_calendar can output iCal data, but can it READ from an external source? I can’t see anything in the plugins docs that suggests it can.

Anyone done this?

Offline

#2 2017-07-18 10:33:20

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,787
Website

Re: smd_calendar advice

As far as I recall (it’s been a loooong time since I looked at this plugin) it only reads event content from articles. But I like the idea of showing external data. Not sure how to do that in the plugin natively though.

For now, I wonder if it’s possible to write a plugin that hooks into Google Calendar’s API and sucks in the events to create/update articles? Presumably it has an API, such that when an event is published you can ‘subscribe’ to it and be notified of changes? If that event has some UUID and that reference can be stored in (e.g.) a custom field, then any notification that contains the same ID means the article content needs updating. Anything not seen = new article.

Bit hacky, but might work.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2017-07-18 11:26:12

CodeWalker
Member
From: Hampshire, UK
Registered: 2010-01-08
Posts: 110
Website

Re: smd_calendar advice

Thanks for the input Stef.

It sure does have an API. I’ve actually cracked the nut a different way. I used a jQuery Calendar (www.fullcalendar.io) that has multiple source support. I hooked it up to a new GCal api Key and then threw in an article_custom tag into its events array and presto! The bonus is the calendar is Ajaxed.

Just one teeny question: How do i get the value of the article expiry field in iso8601 format? Im using that to drive the event end.

On a side note, if you did feel like revising smd_cal, might get you along way to build on top of FullCalendar and provide an easy set of tags for providing event sources and/or/both the TXP section to pull events from.

Last edited by CodeWalker (2017-07-18 11:44:43)

Offline

#4 2017-07-18 11:34:24

CodeWalker
Member
From: Hampshire, UK
Registered: 2010-01-08
Posts: 110
Website

Re: smd_calendar advice

If it helps anybody, heres my script that use both TXP articles and a Google Calendar to display them on one calendar.

<script>
$(document).ready(function() {
  var today = new Date();
  $('#calendar').fullCalendar({
    header: {
      center: 'title',
      right: 'today',
      left: 'prev,next'
    },
    defaultDate: today,
    navLinks: false,
    editable: false,
    eventLimit: true,
    eventSources: [{
      googleCalendarApiKey: 'YOURAPI',
      googleCalendarId: 'YOURGOOGLECALENDARID',
      className: 'gcal-event'
    }, ],
    events: [
              <txp:article_custom limit="999999" exclude="3" section="events">
                  {
                  title: '<txp:title/>',
                  url: '<txp:permlink />/',
                  start: '<txp:posted format="iso8601" />',
                  className: 'site-event'
                  },
              </txp:article_custom>
            ]
  });
});
</script>

Offline

#5 2017-07-18 11:49:21

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,787
Website

Re: smd_calendar advice

CodeWalker wrote #306318:

It sure does have an API. I’ve actually cracked the nut a different way. I used a jQuery Calendar (www.fullcalendar.io) that has multiple source support. I hooked it up to a new GCal api Key and then threw in an article_custom tag into its events array and presto! The bonus is the calendar is Ajaxed.

Sweet! If the plugin can learn from this or do anything differently to help, please let me know.

Just one teeny question: How do i get the value of the article expiry field?

Via a tag: <txp:expires /> which has the format attribute to export the value as you like it. Or via <txp:custom_field name="expires" /> (although this will fail if the article has no expiry, with a field_not_found error). Note to self: fix this.

if you did feel like revising smd_cal, might get you along way to build on top of FullCalendar and provide an easy set of tags for providing event sources and/or/both the TXP section to pull events from.

I’ll have to look into this one day. The current implementation (sitting atop an ancient class borrowed from an old plugin) leaves a lot to be desired.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB