Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2017-09-12 11:06:17
- david@druna.cz
- Member
- Registered: 2017-07-25
- Posts: 41
Expiration datepicker
Is there a datepicker for expiration date somewhere? Feels cumbersome to type into the separated fields for year, month… by hand. Haven’t found any plugin solving this yet.
Offline
Re: Expiration datepicker
That would be a reasonable core feature, especially with future custom fields. Will investigate on jQuery UI side and report back.
Offline
Re: Expiration datepicker
etc wrote #306964:
That would be a reasonable core feature, especially with future custom fields. Will investigate on jQuery UI side and report back.
The JQ-ui date picker widget was once tried in Core (Write panel) – quite a long time ago (pre 4.6, IIRC maybe philwareham remembers). However it had very poor keyboard accessibility (the user was locked between the date input field and the trigger button, I think) and the feature was backed-out. But maybe as a plugin? The default theme already has all the styling required.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
Re: Expiration datepicker
You can try this plugin, it seems to work ok for me:
# Name: etc_datepicker v0.2.2
# Type: Admin plugin
#
# Author:
# URL:
# Recommended load order: 5
# .....................................................................
# This is a plugin for Textpattern CMS - http://textpattern.com/
# To install: textpattern > admin > plugins
# Paste the following text into the 'Install plugin' box:
# .....................................................................
YToxMTp7czo0OiJuYW1lIjtzOjE0OiJldGNfZGF0ZXBpY2tlciI7czo2OiJhdXRob3IiO3M6
MDoiIjtzOjEwOiJhdXRob3JfdXJpIjtzOjA6IiI7czo3OiJ2ZXJzaW9uIjtzOjU6IjAuMi4y
IjtzOjExOiJkZXNjcmlwdGlvbiI7czowOiIiO3M6NDoiY29kZSI7czoxODM2OiJyZWdpc3Rl
cl9jYWxsYmFjaygnZXRjX2RhdGVwaWNrZXInLCAnYWRtaW5fc2lkZScsICdib2R5X2VuZCcp
Ow0KDQpmdW5jdGlvbiBldGNfZGF0ZXBpY2tlcigkZXZlbnQsICRzdGVwKQ0Kew0KJHNjcmlw
dCA9IDw8PEpTDQokKGRvY3VtZW50KS5yZWFkeShmdW5jdGlvbiAoKSB7DQp0ZXh0cG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HNjcmlwdF9qcygkc2NyaXB0KTsNCn0iO3M6NDoi
dHlwZSI7czoxOiIzIjtzOjU6Im9yZGVyIjtzOjE6IjUiO3M6NToiZmxhZ3MiO3M6MToiMCI7
czo0OiJoZWxwIjtzOjA6IiI7czozOiJtZDUiO3M6MzI6IjJkZjZiYjMxN2QxM2Y2ZTkzYzMy
ZTVlYmQ0ZGU5MDFiIjt9
Last edited by etc (2017-09-15 08:34:07)
Offline
Re: Expiration datepicker
etc wrote #306972:
You can try this plugin, it seems to work ok for me:
Seems to work fine in Safari and Firefox. Can’t select a date from the keyboard, but you knew that already.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
Re: Expiration datepicker
phiw13 wrote #306966:
The JQ-ui date picker widget was once tried in Core (Write panel) – quite a long time ago (pre 4.6, IIRC maybe philwareham remembers).
Yes Philippe is correct, I toyed with date-pickers for a while but the retooling necessary was beyond my scope and the accessibility was not great at the time. I do still have the way I’d want the UI to appear in my mockups (as a non-intrusive icon to the side of the date entry fields). And I keep the jQuery UI datepicker widget styling up to date just in case (although the jQuery UI team is doing a total rewrite of that widget at the moment to improve touch and accessibility support).
Maybe one day date and time HTML5 input
fields will have universal browser support and we can just use that. Safari seems to be dragging it’s heels on that, Firefox support is nearly here, and IE won’t ever have it (though Edge does).
In the meantime I’d like to see the current (3) fields that form the date inputs to at least change format depending on language used – at the moment it’s hardcoded to the US format of YYYY MM DD when most of the world uses DD MM YYYY.
Offline
Re: Expiration datepicker
The full proof way would be to have 3 pull-down menus, as 90s as the method might be:)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#8 2017-09-13 12:24:28
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,473
Re: Expiration datepicker
philwareham wrote #306976:
(…) at the moment it’s hardcoded to the US format of YYYY MM DD when most of the world uses DD MM YYYY.
I always thought YYYY MM DD is ISO 8601, and for archiving it makes sense.
Offline
Re: Expiration datepicker
GugUser wrote #306978:
I always thought YYYY MM DD is ISO 8601, and for archiving it makes sense.
Yes but people don’t generally write in ISO 8601, they write in their natural language.
Offline
Offline
Re: Expiration datepicker
On a technical note, if we know the language (and hence locale?) in use on the admin side for the current user, can we reliably obtain the “preferred date format” for that locality? If so (e.g. ask PHP and find that dd/mm/yyyy is the preferred order for en-gb) there shouldn’t be any issue swapping the order of the individual date/month/year fields to match. And, if it can’t be obtained, for whatever reason, default to YYYY-MM-DD order like we do today.
That’s fine for multi-input boxes, but single input boxes represent a real headache. I’ve done it before on a separate project and it hurts. The date picker usually needs to be told what format is acceptable, so any existing dates need to be in that format before the picker is invoked. Plus, the input field needs to be told what format to accept. They MUST match. Manually altering the dates can wreak havoc, and I found some annoying corner cases where dates would show as ‘invalid’ or throw yucky PHP errors on submission because they didn’t quite match the format (e.g. omitting the leading 0 on days/months). It’s a minefield and I rather like my legs.
If date pickers can be invoked such that:
- they can correctly direct each part of the chosen date into separate boxes based on their name/ID; and
- they can read the “currently set” date from separate input boxes via their name/ID and display it in the widget
then that would be my preferred solution. Best of both worlds: unambiguous date display, unambiguous intepretation of incoming date portions, user-friendliness of a single date picker.
Now, as for time pickers…. urgh!
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
Re: Expiration datepicker
Bloke wrote #306981:
If date pickers can be invoked such that:
- they can correctly direct each part of the chosen date into separate boxes based on their name/ID; and
- they can read the “currently set” date from separate input boxes via their name/ID and display it in the widget
then that would be my preferred solution. Best of both worlds: unambiguous date display, unambiguous intepretation of incoming date portions, user-friendliness of a single date picker.
Yes they can, kinda.
Offline