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.

Comments

netsensei’s picture

Status: Active » Needs review
StatusFileSize
new7.23 KB

Patch attached

sdboyer’s picture

Status: Needs review » Needs work

I 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 :)

zualas’s picture

I 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.

simon georges’s picture

Closing #752578: Add custom date format as a duplicate of this one.

AdrianB’s picture

Subscribing.

cyberwolf’s picture

Status: Needs work » Needs review
StatusFileSize
new44.66 KB
new1.07 KB

IMO 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.

cyberwolf’s picture

StatusFileSize
new2.14 KB

I forgot to modify the 'Node updated date' content type in my previous patch, so here's a new one.

Shadlington’s picture

Subbing

EDIT: I tested the patch against the D7 version and confirm that it works.

hnln’s picture

subscribe

zilverdistel’s picture

subscribing

thechanceg’s picture

Thanks 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.

hnln’s picture

patch #7 delivers

zilverdistel’s picture

Status: Needs review » Reviewed & tested by the community

marking this as rtbc might help getting this committed

amitkeret’s picture

any 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.

amitkeret’s picture

StatusFileSize
new1.55 KB

managed 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.

amitkeret’s picture

Status: Reviewed & tested by the community » Needs review

sorry, forgot to change status...

cyberwolf’s picture

aaronbauman’s picture

StatusFileSize
new2.69 KB

#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

aaronbauman’s picture

Status: Needs review » Needs work
StatusFileSize
new3.21 KB

OK, 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).

aaronbauman’s picture

Status: Needs work » Needs review

grr

japerry’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)

Drupal 6 is no longer supported, closing.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.