Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#781 2012-01-05 11:42:38
Re: smd_calendar: complete schedule / event / calendar / diary
colak wrote:
Is there a way to use custom fields for start-end dates?
Yep. See the datefields
attribute.
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
#782 2012-01-05 17:06:26
Re: smd_calendar: complete schedule / event / calendar / diary
thanks stef. I was wondering what you meant with that.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#783 2012-01-05 21:40:20
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: smd_calendar: complete schedule / event / calendar / diary
Yiannis, see the attribute’s description in the plugin help or here.
Something like datefields="custom_1,custom_2"
.
Offline
#784 2012-01-06 07:47:51
Re: smd_calendar: complete schedule / event / calendar / diary
Thanks Els, I am on it:) What I answered to stef is that i did not understand from the documentation that the “datefields” are referring to custom fields.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#785 2012-01-06 08:24:22
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: smd_calendar: complete schedule / event / calendar / diary
colak wrote:
I am on it:)
Ah, misunderstood ;)
Offline
#786 2012-01-06 08:25:40
Re: smd_calendar: complete schedule / event / calendar / diary
Els wrote:
Ah, misunderstood ;)
No problem:) Thanks so much for jumping in anyway.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#787 2012-01-09 23:55:22
Re: smd_calendar: complete schedule / event / calendar / diary
Which version of this plugin would work with Textpattern 4.2.0? And would it be fairly stable?
Thanks!
Offline
#788 2012-01-10 00:04:34
Re: smd_calendar: complete schedule / event / calendar / diary
floodfish wrote:
Which version of this plugin would work with Textpattern 4.2.0?
Although untested, they should all work.; even the latest beta. There’s nothing in the code to prevent it working on older versions down to about Txp 4.0.8, but I specify 4.4.1 as minimum right now simply because that is the most secure, up-to-date version of Textpattern.
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
#789 2012-01-10 00:07:25
Re: smd_calendar: complete schedule / event / calendar / diary
Although untested, they should all work.; even the latest beta. There’s nothing in the code to prevent it working on older versions down to about Txp 4.0.8, but I specify 4.4.1 as minimum right now simply because that is the most secure, up-to-date version of Textpattern.
Aha! Great. Thanks, Stef!
Offline
#790 2012-01-14 19:39:43
Re: smd_calendar: complete schedule / event / calendar / diary
Hallo,
I am using smd_calendar on a website I am working on: http://iqabc.w4yserver.at/textpattern441/programm/
The only problem I have, the links (http://iqabc.w4yserver.at/textpattern441/programm/?m=12&y=2011) generated by the back and forward button and the month selection field won’t work, while the calendar fields (http://iqabc.w4yserver.at/textpattern441/?date=2012-01-27&s=programm) work correctly.
Playing around with the links from the calendarfields, selecting a month would work with this link http://iqabc.w4yserver.at/textpattern441/?date=2012-02&s=programm
Was this issue discussed before, I couldn’t find it through the forum search?
Best Regards,
Peter
Offline
#791 2012-02-16 11:17:43
Re: smd_calendar: complete schedule / event / calendar / diary
Ack!
I’ve just found a hole in smd_calendar when using datefields
. According to the MySQL docs a “Date” is a string of characters in the format “YYYY-MM-DD”. If we’re using the Posted/Expires fields that’s fine because Txp stores them that way internally.
But if we’re using a custom field, we cannot guarantee that’s the format the data will be stored in, because custom fields are freeform text. Even using a date picker might not solve the issue if it output DD/MM/YYYY when a date is chosen.
When I go to retrieve a date from the database for inclusion on the calendar I use MySQL’s UNIX_TIMESTAMP()
function to get “the date” from the custom field and check it falls within the calendar’s range. MySQL, stupidly yet dutifully, looks at DD/MM/YYYY and says “That’s not a date in my expected format of YYYY-MM-DD”, and returns NULL. Hence, the date isn’t used in the calculation and the events don’t show up.
There are a few possible approaches or solutions, none of them ideal:
1) Format the custom field into YYYY-MM-DD from the date picker (if it allows it) or implore your user to always put them in that format
2) Convert the custom field contents to YYYY-MM-DD using PHP when you hit ‘Save’ on the Write tab (messy, and impractical for the calendar plugin to implement)
3) Use MySQL’s STR_TO_DATE()
function in smd_calendar when retrieving the custom field from the database to convert it to the expected format before passing it to UNIX_TIMESTAMP()
. Unfortunately, STR_TO_DATE()
’s second mandatory parameter is a format string depicting the exact format the custom field’s date is stored in. Of course, I cannot know in advance if the person/date picker has used dd-mm-yyyy or dd-mmm-yyyy or mm-dd-yyyy or dd/mm/yyyy or dd.mm.yyyy or any permutation thereof, so I won’t know what format string to supply (and it only allows one string, not a list of them)
4) Anything else…?
If anybody has any thoughts on how this might be achieved in practice so the plugin works better, please let me know. I’m fresh out of ideas. In the meantime, treat this as a heads-up that needs to go in the documentation: always put your custom datefield dates in YYYY-MM-DD format. Thanks.
Last edited by Bloke (2012-02-16 11:19:40)
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
#792 2012-02-21 20:39:44
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,473
Re: smd_calendar: complete schedule / event / calendar / diary
The answer to my problem is probably simple but I can’t find them:
I would like to publicize a future event. If I create an article and put the post date in the future, then I can view the event in the calendar with this code:
<txp:smd_calendar size="small" firstday="1" id="cal-events" section="events" time="future" expired="0" />
This has the disadvantage that the RSS feed for the same section is valid only on the day of the event.
How could I publish the event article with the current date but set in the expires date when it takes place, so that the event link in the calendar get to the article?
Thank you for an answer.
Offline