Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#196 2009-03-13 19:26:55

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,468
Website GitHub

Re: smd_calendar: complete schedule / event / calendar / diary

Aww shucks, thanks for all the thanks everyone :-) Just doing my bit.

I think this version should help out quite a few people. I’d be especially interested to hear if using datefields to specify start and end dates solves the DST / time zone conundrum. Since the values in your nominated custom field(s) are simply just seen as text to TXP, it has no notion of its ‘data type’ and therefore cannot apply any automatic correction to it.

Thus (I hope) that a start date of 30-Jul-2009 14:00:00 remains that way no matter what your server / country / TXP claims the real time is — both at the time a visitor views your site, and from your article’s perspective. Whether that’s a good thing or not remains to be seen. If anything. it’s not a true solution. But if it’s a workaround at least it’s something to work with / refine.

Last edited by Bloke (2009-03-13 19:27:58)


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#197 2009-03-15 00:33:44

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: smd_calendar: complete schedule / event / calendar / diary

Grmpff, looks like I have to start working on the calendar on my site because of missing long lasting British developer resistence. Thanks for that extra work still to do dear Stef!

Did we talk about fully featured iCal subscriptions and iCal offerings yet :-)


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#198 2009-03-15 11:15:28

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,468
Website GitHub

Re: smd_calendar: complete schedule / event / calendar / diary

merz1 wrote:

Did we talk about fully featured iCal subscriptions and iCal offerings yet :-)

Kind of. It works one way at least. Syncing a TXP calendar to other people’s iCals — which I don’t think is possible in a useful manner, though I haven’t looked into the feasibility yet, and know nothing about the iCal spec — would have to wait until the increased plugin size limit becomes mainstream. I’m fresh out of space.

But during my cursory think-through, I’m of the opinion it shoud be a companion plugin because I don’t think I’m clever enough to implement it. Unless I’m mistaken (wouldn’t be the first time!), it would have to read an iCal XML document and create articles based on the content, right? That is, some kind of ‘import’ functionality, yes? It would have to offer a shedload of configuration options to deal with the following situations (and more — these are off the top of my head) :

1) How you want the start and end times imported (into your own datefields or the TXP date fields)
2) How to deal with invalid dates (if present — might not need to worry if the iCal spec performs error checking already)
3) How to deal with duplicate URL titles
4) More specifically, how to work out the frequency if an event occurs more than once in the XML document. e.g. if the importer code saw:

SUMMARY:event1 DTSTART=15-03-2009 21:00:00 DTEND=15-03-2009 22:00:00
SUMMARY:event1 DTSTART=22-03-2009 21:00:00 DTEND=22-03-2009 22:00:00
SUMMARY:event1 DTSTART=29-03-2009 21:00:00 DTEND=29-03-2009 22:00:00
...

it assumes (rightly? wrongly?) it is the same event because the title is the same, but how does it know to set the frequency field to 1 week? And what if there’s one date that’s ‘off’ by a day or two and needs to be manually added? Do you tell the importer to put ‘weird’ dates in a particuar custom field (your extrafield)? How do you define ‘weird’ programmatically? :-s

So currently — and I know it seems that every time you come up with some idea I shoot it down, it’s not personal! — unless someone can show me otherwise, I’d like to brush this feature request under the carpet and forget it exists :-) Maybe you can convince me otherwise or convince someone better at coding than I am to tackle it, because it looks like a whole heap of work to me that I have neither the energy to write, nor a Mac to test.

Last edited by Bloke (2009-03-15 11:16:19)


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#199 2009-03-16 11:50:43

decoderltd
Member
From: London
Registered: 2006-06-20
Posts: 248
Website

Re: smd_calendar: complete schedule / event / calendar / diary

Hi Stef,

Thanks again for the great plug-in.

I’ve just uploaded the new version of the plug-in and I’m getting a completely blank site with the following error –
Fatal error: Call to undefined function smd_expand_daterange() in /var/www/vhosts/enfieldbeekeepers.org.uk/httpdocs/textpattern/lib/txplib_misc.php(570) : eval()'d code on line 1666

Not sure if I’ve created the error somewhere along the way.

Offline

#200 2009-03-16 12:05:34

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,468
Website GitHub

Re: smd_calendar: complete schedule / event / calendar / diary

decoderltd wrote:

@Fatal error: Call to undefined function smd_expand_daterange()

Yowzers. I was running perilously close to the (current) maximum size of a plugin and developing in the newer SVN environment with the lifted size restriction. I thought it was just fine, but could you please make sure that the plugin has not been cut short by accident. Check the source code. It should end with:

...
	} else {
		$out[] = strftime($fmt, strtotime($rng[0]));
	}
	return $out;
}

EDIT: and did you install the compressed plugin?

Last edited by Bloke (2009-03-16 12:06:08)


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#201 2009-03-16 12:15:39

decoderltd
Member
From: London
Registered: 2006-06-20
Posts: 248
Website

Re: smd_calendar: complete schedule / event / calendar / diary

Hi Stef,

Thank you for your prompt reply. It is indeed a case of the code being truncated, I’ve tried both compressed (zip) and uncompressed version. but neither shows the full code. Zipped ends at ...lg4cPv/wy/uLrvWTy8Kuv9r9+OOkcfvh/Abj6Z9o/AwIA, uncompressed at ...ZjU4ZDc3YjFkOTVhMjczNTU3N2E0OTBlZDU4ODI5NWQiO30= – not sure if that helps you!

Offline

#202 2009-03-16 12:20:08

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,468
Website GitHub

Re: smd_calendar: complete schedule / event / calendar / diary

decoderltd wrote:

Thank you for your prompt reply. It is indeed a case of the code being truncated

So whereabouts does the code end in the Edit Plugin code window? What are the last 4 or 5 lines of actual PHP code you see (just so I can get a handle on where it might be).

Zipped ends at ...lg4cPv/wy/uLrvWTy8Kuv9r9+OOkcfvh/Abj6Z9o/AwIA, uncompressed at ...ZjU4ZDc3YjFkOTVhMjczNTU3N2E0OTBlZDU4ODI5NWQiO30= – not sure if that helps you!

Weird, same on mine and it installs fine. Hmmmm.

EDIT: shite, no it doesn’t. Pants. Juts tried it on 4.0.7 and it gets cut off at

	return (!in_array(0, $show)) ? true : false;
}

// Convert date ranges like 24-Oct-08 => 5-Nov-08 to an 

urk!

EDIT2: crapola. It’s because of the line endings. With UNIX line endings (\n) it’s fine but when exported, the plugin composer (or plugin importer) converts it to DOS line endings (\r\n), which takes it over the size limit. Nuts. Gotta go and think this through.

Last edited by Bloke (2009-03-16 12:51:12)


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#203 2009-03-16 12:27:57

decoderltd
Member
From: London
Registered: 2006-06-20
Posts: 248
Website

Re: smd_calendar: complete schedule / event / calendar / diary

Hi Stef,

The last lines of the plug-in code are:

// Check the passed timestamp against every time restriction and return true if it passes them all function smd_include_event($ts, $now, $ign, $time, $from, $to, $month) {
$show = array();
$show[] = !in_array(date("d-M-Y", $ts), $ign);
switch($time) {
case "any": break;
case "future": $show[] = ($ts > $now) ? true : false; break;
default : $show[] = ($ts < $now) ? true : false; break; // The past }
if ($from) { $show[] = ($ts >= strtotime($from)) ? true : false; }
if ($to) { $show[] = ($ts <= strtotime($to)) ? true : false; }
if ($month) { $show[] = (date("Y-m", $ts) == $month) ? true : false; }

return (!in_array(0, $show)) ? true : false; }

// Convert date ranges like 24-Oct-08 => 5-Nov-08 to an

Last edited by decoderltd (2009-03-16 12:29:43)

Offline

#204 2009-03-16 12:37:26

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,468
Website GitHub

Re: smd_calendar: complete schedule / event / calendar / diary

Yep, same as me.

OK, interim solution until I can recompile the plugin tonight and/or figure out why DOS line endings are being put on the file. Download the code without any comments in it and paste it over the banjaxed code in the Edit Plugin window.

Apologies for that. I thought it fit fine. That’ll teach me to not actually test it.

Last edited by Bloke (2009-03-16 12:38:19)


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#205 2009-03-16 12:41:23

decoderltd
Member
From: London
Registered: 2006-06-20
Posts: 248
Website

Re: smd_calendar: complete schedule / event / calendar / diary

Thanks Stef, that’s done the trick.

Offline

#206 2009-03-16 13:12:43

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: smd_calendar: complete schedule / event / calendar / diary

Re. iCal: Stef, thanks for the link to the iCal export form! I saw that but had forgotten about it.

You’re right. iCal import is a totally different thing. I think it’s easier to use an external Google or airset.com calendar widget as a nicely formatted workaround instead :)

…you come up with some idea I shoot it down, it’s not personal!

I know and I like to stretch the limits a little bit this way :)


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#207 2009-04-13 09:20:51

cynicalpink
Member
Registered: 2006-08-21
Posts: 11
Website

Re: smd_calendar: complete schedule / event / calendar / diary

I’d like to display 12 months, beginning with the current month, of static mini calendars on a single page. So far I cannot figure out the correct way to do it. I was hoping the following would work, but no go.

<txp:smd_calendar time="future" firstday="0" month="<txp:smd_cal_now />" static="true" />

<txp:smd_calendar time="future" firstday="0" month="<txp:smd_cal_now offset="1 month" />" static="true" />

<txp:smd_calendar time="future" firstday="0" month="<txp:smd_cal_now offset="2 months" />" static="true" />

and so forth.

What’s the best way to go about it?

Also, is there a way to not display the events as links?

Offline

#208 2009-04-13 09:54:35

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,468
Website GitHub

Re: smd_calendar: complete schedule / event / calendar / diary

cynicalpink

You were very close :-)

<txp:smd_calendar time="future" firstday="0" month='<txp:smd_cal_now format="%m" />' static="1" />
<txp:smd_calendar time="future" firstday="0" month='<txp:smd_cal_now format="%m" offset="1 month" />' static="1" />
<txp:smd_calendar time="future" firstday="0" month='<txp:smd_cal_now format="%m" offset="2 months" />' static="1" />
...

You need the format attribute to return a numeric representation of the month from 1 to 12, hence %m.

Also, is there a way to not display the events as links?

Yes, it is only that way by default. If you use the form attribute you can configure how to display events, for example if you added form="my_events" then you could put this in your my_events form:

<txp:title />
<div class="times">
Start: <txp:posted />
End: <txp:expires />
</div>

If you want to go further still, look at the cellform attribute in the plugin help. Hope that gets you going.

Last edited by Bloke (2009-04-13 10:37:35)


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#209 2009-04-13 10:51:56

cynicalpink
Member
Registered: 2006-08-21
Posts: 11
Website

Re: smd_calendar: complete schedule / event / calendar / diary

I knew I was missing something obvious. Thanks for the quick response.

Offline

#210 2009-04-14 10:16:36

decoderltd
Member
From: London
Registered: 2006-06-20
Posts: 248
Website

Re: smd_calendar: complete schedule / event / calendar / diary

Hi all,

I’m trying to put together a form that lists other future events within the category of the event article currently being viewed (i.e. if you are viewing details of an event which is in the ‘courses’ category then other events from the category would be listed). I’ve got this far but it’s not outputting any events although there are some –

<h6><txp:category1 title="1" /></h6>
<txp:if_category>
<txp:smd_article_event section="diary"  stepfield="custom_1" skipfield="custom_2" omitfield="custom_3" extrafield="custom_4" sort="Posted,Title asc" time="future" wraptag="dl" >
      <txp:if_different>   
        <dt><txp:permlink><txp:title/></txp:permlink></dt>
      </txp:if_different>
        <dd><txp:posted /></dd>
      </txp:smd_article_event>
<txp:else />
<p>No other scheduled <txp:category1 title="1" /> at the moment.</p>
</txp:if_category>

I’m also considering using some form of tooltip on calendar entries so you could quickly view Event name, location, time without having to go to the full article. Is there any particular javascript (preferably jQuery) that anyone can recommend and is it straightforward to implement?

Thanks in advance for any help.

Offline

Board footer

Powered by FluxBB