The issue
While working in panels, I've build a panel variant for the node template. In the content of the panel, I added the 'node: created date' and 'node: updated date' panes. (Through 'add content' on the 'content' tab of the variant)
Each added pane is configurable. When you want to configure the 'node: created date' and 'node: updated date' panes, you'll notice that you can't set a custom date format. Only the 3 default available date formats that come with Drupal (short, medium and long) are available.
Cause
After some digging, I related this to ctools and the node_created.inc and node_updated.inc plugins (in content_types/node_context) didn't support this.
Solution
I also noticed that Views *does* support custom date formatting in quite an extensive fashion. While my first attempt was to allow extra formatters through the Date API module, I abandoned that approach: I didn't want to put an extra dependency on ctools. So I just ported the Views code in ctools.
Patch with this new feature attached to the issue.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | date-format-types-776268.patch | 3.21 KB | aaronbauman |
| #18 | date-format-types-776268.patch | 2.69 KB | aaronbauman |
| #15 | date-format-types-776268-6.patch | 1.55 KB | amitkeret |
| #7 | date-format-types-776268-7.patch | 2.14 KB | cyberwolf |
| #6 | date-format-types-776268-6.patch | 1.07 KB | cyberwolf |
Comments
Comment #1
netsensei commentedPatch attached
Comment #2
sdboyer commentedI like where this is going in principle, but I wonder how applicable the time range values are for a situation where, as I'm thinking of it, we should only really expect to have a single value. So either strip those parts out, or explain to me why they should be retained :)
Comment #3
zualas commentedI applied the patch, but looks like the "Custom" format doesn't save my input in the textbox, and the date appears blank. Other selections work fine.
Comment #4
simon georges commentedClosing #752578: Add custom date format as a duplicate of this one.
Comment #5
AdrianB commentedSubscribing.
Comment #6
cyberwolf commentedIMO it's better to just display custom date format types in the dropdown in addition to the default ones (small, medium and large) and NOT to add any custom formatting options in this form as suggested initially, to prevent bloating and code duplication.
Attaching a patch for the D7 branch and a screenshot.
Comment #7
cyberwolf commentedI forgot to modify the 'Node updated date' content type in my previous patch, so here's a new one.
Comment #8
Shadlington commentedSubbing
EDIT: I tested the patch against the D7 version and confirm that it works.
Comment #9
hnln commentedsubscribe
Comment #10
zilverdistel commentedsubscribing
Comment #11
thechanceg commentedThanks Cyberwolf! The patch in #7 worked flawlessly for me with the latest -dev (2011-Sep-08) version of ctools.
Any reason why this hasn't been committed yet? Seems like this issue would be coming up kind of often.
Comment #12
hnln commentedpatch #7 delivers
Comment #13
zilverdistel commentedmarking this as rtbc might help getting this committed
Comment #14
amitkeret commentedany chance of creating a patch for D6?
system_get_date_types() is a D7 function, and the (kind of-)equivalent function date_get_formats() returns much more results.
trying to use date_get_format_types() outputs the formats' names and titles, but not the format (which is needed by the render function)
any help is appreciated.
Comment #15
amitkeret commentedmanaged to create the following patch, first draft.
this is basically taken from date_api.admin.inc's way of rendering the select boxes for all formats.
comments are welcome.
Comment #16
amitkeret commentedsorry, forgot to change status...
Comment #17
cyberwolf commentedLooks like this got fixed in #1233424: Impossible to choose date format in node created date.
Comment #18
aaronbauman#15 works great for me.
thanks for the patch.
I'm attaching an updated version that does the exact same thing for $node->changed (ie. "Node last updated date")
@cyberwolf: #1233424 may be the same issue, but that ticket was a fix for 7.x; this is 6.x
Comment #19
aaronbaumanOK, spoke too soon.
This patch will not work because it uses the function date_get_formats() from date_api, which we should not add as a dependency.
(Also it sends the words "small", "medium" and "large" as format strings to format_date(), which doesn't work for obvious reasons).
The attached patch addresses both these issues.
Additionally, the pane admin form will now show only the assigned default and assigned custom date format string, instead of every single possible format string. (the way views node field does).
Comment #20
aaronbaumangrr
Comment #21
japerryDrupal 6 is no longer supported, closing.