Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#496 2010-03-24 10:45:47
Re: smd_calendar: complete schedule / event / calendar / diary
saccade wrote:
It would be nice to have an additional attribute like “sort”.
I can’t see a reason why your mod won’t work. Should be fine.
EDIT: Oh wait, maybe not. the uPosted < $ts is checking the UNIX timestamp of the Posted date against the last timestamp in the current month. That might not be what you want because you need the timestamp of the custom_1 field in this case. You might have to alter it to:
$sql2 = $stati . " HAVING UNIX_TIMESTAMP(custom_1) <= ".$ts_last . $expired . $extrasql ." ORDER BY custom_1 ASC";
I should probably add sort to the list of things to do, since you can now specify your own fields to hold dates/times. Thanks for the nudge.
Last edited by Bloke (2010-03-24 11:08:50)
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
#497 2010-03-30 21:14:47
- nardo
- Member

- From: tuvalahiti
- Registered: 2004-04-22
- Posts: 743
Re: smd_calendar: complete schedule / event / calendar / diary
I have a recurring event on the second Thursday of the month. The implementation works fine – except when the first Thursday is the 1st of the month … ! In which case, smd_calendar places the event on the 3rd Thursday of the month
Has anyone reported a similar bug?
Figure it’s to do with time (server, local)… ?
Offline
#498 2010-03-30 21:52:16
Re: smd_calendar: complete schedule / event / calendar / diary
Yes, I’ve seen such strangeness. With first of month in my case. Exactly the same happens.
Hey Bloke, sorry for not finishing the monologue I started. I’m very busy these days, and I’l try to catch up soon.
All the best!
Pascal
Offline
#499 2010-03-31 11:42:03
Re: smd_calendar: complete schedule / event / calendar / diary
nardo wrote:
except when the first Thursday is the 1st of the month … ! In which case, smd_calendar places the event on the 3rd Thursday of the month. Has anyone reported a similar bug? Figure it’s to do with time (server, local)… ?
Might be related. If it’s not that, then it’s a definite bug in the plugin. Or it might be that and a bug in the plugin *sigh*
PascalL
No probs. Kinda swamped lately myself. Must make time to focus on this plugin…
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
#500 2010-03-31 22:23:25
- nardo
- Member

- From: tuvalahiti
- Registered: 2004-04-22
- Posts: 743
Re: smd_calendar: complete schedule / event / calendar / diary
Bloke wrote:
Might be related. If it’s not that, then it’s a definite bug in the plugin. Or it might be that and a bug in the plugin *sigh*
Can confirm – my issue is on a website where server is running PHP 5.2.13
Offline
#501 2010-04-01 21:06:25
Re: smd_calendar: complete schedule / event / calendar / diary
Hi Stef et al,
Please say “You should start a new thread” if I should start a new thread to ask the following…
I may end up using smd_calendar (stunned by it’s facility… thank you), but for now I am using 1% of it’s Oomph to help me compare dates so I can show a list of articles (so not even using the smd_calendar tag) — I have an Events section, each Article there has a custom field (Event date) set. On the home page I am then just trying to show a list of those in the future.
I am trying to get two values that the lovely smd_if can compare, namely the date now and the date from the ‘Event date’ field.
The following reports a unix timestamp number that is the same (it’s ‘now’), that is, the numEvent is also defaulting to ‘now’ as opposed to reflecting the content of the ‘Event date’ custom field :(
<txp:variable name="numEvent" value='<txp:smd_cal_now format="%s" now="<txp:custom_field name="Event date" />" />' />
<txp:variable name="numEvent" />
<hr />
<txp:variable name="numNow" value='<txp:smd_cal_now format="%s" />' />
<txp:variable name="numNow" />
I’ve tried for a few hours (embarrassing) and failed.
Thanks for any hint’s or kicks in the right direction. Cheers, -Alan
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
#502 2010-04-01 21:30:22
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: smd_calendar: complete schedule / event / calendar / diary
alanfluff wrote:
<txp:variable name="numEvent" value='<txp:smd_cal_now format="%s" now="<txp:custom_field name="Event date" />" />' />
Don’t know if it will solve your problem, but first change the quotes:
<txp:variable name="numEvent" value='<txp:smd_cal_now format="%s" now=''<txp:custom_field name="Event date" />'' />' />
Offline
#503 2010-04-01 21:39:56
Re: smd_calendar: complete schedule / event / calendar / diary
Thanks Els. It’s odd, both versions ‘work’ (do not report errors), but thanks for the quotes correction. However both produce the time as ‘now’, changing at each refresh, and not the value of the custom field.
I’ve just started to look at msv_if_custom_article_date, but at first stab/attempt, I just got errors (probably me…).
I’ll keep persevering :)
Last edited by alanfluff (2010-04-01 21:40:35)
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
#504 2010-04-01 21:48:21
Re: smd_calendar: complete schedule / event / calendar / diary
Els beat me to it, and is right with the syntax. She knows which side her apostrophes and double quotes are buttered.
Alternatively, try txp:variable as a container:
<txp:variable name="numEvent"><txp:smd_cal_now format="%s" now='<txp:custom_field name="Event date" />' /></txp:variable>
And remember that if you’re putting this inside an article itself to escape the tag with double-equals signs so Textile doesn’t bungle things. Can’t see any other surface reason why this wouldn’t work. What format is the date in your custom field?
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
#505 2010-04-01 21:59:12
Re: smd_calendar: complete schedule / event / calendar / diary
Arghgh!
What format is the date in your custom field?
It was:
29/03/2010
…and no joy. It’s now:
29-03-2010
and it works. Why didn’t I think to change that… So sorry for using cycles — thanks Stef and Els.
Cheeky extra question — the ‘/’ comes from the lovely date picker courtesy of glz_custom_fields — if I can’t change that, is there a way to ask smd_cal_now to accept ‘/’ instead of ‘-’?
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
#506 2010-04-01 22:15:15
Re: smd_calendar: complete schedule / event / calendar / diary
…RTFM Alan… I think I am solving (I think) my ‘Cheeky extra question’ by seeing your use of ‘strftime’ for the format in smd_cal_now. If/when I solve it I’ll drop a note here to close my question and in case it helps others — thanks tons again >^_^<
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
#507 2010-04-01 22:24:55
Re: smd_calendar: complete schedule / event / calendar / diary
alanfluff wrote:
Why didn’t I think to change that…
Because it’s counter-intuitive; it’s not your fault at all! You would expect PHP to handle dd/mm/yyyy but in reality it doesn’t due to the complexities of being able to correctly distinguish the US mm/dd/yyyy from dd/mm/yyyy in all cases. Plus I would guess that PHP’s core functionality here may have stemmed from US programmers :-)
This:
<txp:php>
dmp(strtotime('29-03-2010'));
dmp(strtotime('29/03/2010'));
</txp:php>
only renders one string; the first one. The second one is deemed ‘invalid’ by strtotime (at least in my version of PHP) even though there’s blatantly only one way to interpret that string as a date. Internally, smd_cal_now uses strtotime() so we’re stuck with it.
I was hoping to fix this in the next version of the plugin because it’ll be PHP 5+ so I could have offered an additional parameter to allow you to specify what format you expect the dates to be in. I would then use strptime to parse it, before refactoring the numbers into a format that strtotime can understand. But the caveat on the strptime page states:
Note: This function is not implemented on Windows platforms.
So I’d only swap a solution for another problem :-|
is there a way to ask smd_cal_now to accept ‘/’ instead of ‘-’?
Nope, but there are some wonderful plugins out there that can transmogrify strings before smd_cal_now sees them. I think rah_replace would do it so you could swap / for -.
Last edited by Bloke (2010-04-01 22:27:28)
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
#508 2010-04-01 22:29:33
Re: smd_calendar: complete schedule / event / calendar / diary
Yippee! Thank you for your wonderful explanation — like after-burn on sun-burn after the fruitless hours of Google and trial and error I have spent.
I’ll certainly look at rah_replace and if that does not do it, I’m guessing I could ask jQuery to spot when that field looses focus during edit and replace ‘/’ for ‘-’ on-the-fly (before the human clicks ‘Save’ ;) One way or another, sure to solve it.
THANK you.
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
#509 2010-04-01 23:08:52
Re: smd_calendar: complete schedule / event / calendar / diary
And, thanks in large part to Els and Stef, here is the code that works, 100% — it is not my completed code (lots of other TITLE etc stuff to add, now the logic is working) and probably maybe some intermediary variables are used that could be missed out, but it WORKS and I am SO happy — so happy I wanted to note it here in case it saves anyone else pain.
Summary
For Articles in a section called Events, I am using a custom field, set by the Author, to reflect the date the event is to happen on. The code is designed to take that date and report that there IS a future event, if the date is today or any day in the future. Here’s the code:
<txp:if_custom_field name="Event date">
<txp:variable name="kate" value='<txp:custom_field name="Event date" />' />
<txp:variable name="julie" value='<txp:rah_replace from="/" to="-"><txp:variable name="kate" /></txp:rah_replace>' /><br />
<txp:variable name="numEvent" value='<txp:smd_cal_now format="%s" now=''<txp:variable name="julie" />'' />' />
<txp:variable name="numNow" value='<txp:smd_cal_now offset="-1 day" format="%s" />' />
<txp:smd_if field='<txp:variable name="numEvent" />' operator="gt" value='<txp:variable name="numNow" />'>
<p>There IS something coming up</p>
<txp:else />
<p>There is NOT something coming up</p>
</txp:smd_if>
</txp:if_custom_field>
The date is entered in via the date-picker as dd/mm/yy, the rah_replace gets it to dd-mm-yy (thanks Stef). The smd_cal_now blows pixie dust on the date to allow me to compare it with smd_if (thanks, twice more Stef). The offset=-1 means that an event with todays date will show up also, since I am going to call the list “Future or current events” this fixes the issue where at midnight, the events for today are ‘older’ that the start of today and so would otherwise not show.
Cheers, -Alan
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
#510 2010-04-03 02:12:58
- kevinpotts
- Member

- From: Ghost Coast
- Registered: 2004-12-07
- Posts: 370
Re: smd_calendar: complete schedule / event / calendar / diary
Stef — I’ve searched and scoured this thread trying to find an answer to this question, but I’m stumped.
Take a look at this page
Do see how several spanned events break because of preceding events? I tried to insert a transparent placeholder ABOVE the broken spanned event, but it seems as though the middle or last day of a spanned event does not respect the actual time, so no matter what, I cannot insert a blank placeholder to push the broken events down to line everything up nicely. Any hints on solving this?
Kevin
(graphicpush)
Offline