0

I have a Drupal 8 contrib module AP Style Date that provides a formatter for dates to conform to the AP Style Guide date rules. When using the module Publication Date, this formatter does not come up as an option. The AP Style Date does come up in views and in managing field display for other date types. Is there a modification that needs to be made to the AP Style Date module or something in the publication date that needs to be modified?

1
  • AP Style Date provides a field formatter, which effects how a field (E.g. something that takes user input when creating the content) is displayed. "Publication date" on the other hand provides a display field that outputs a value set in the backend. So it does not expose itself to field formatters for rendering. So in other words, unfortunately they are not compatible. At least as far as I can tell. – 100pic Mar 27 '19 at 5:23
0

The publication date module provides a function to define which formatters can be used. I added a patch, which we maintain locally, to add the defined "timestamp_ap_style" format to the options. Optionally, I could have added it inside a custom module, but the patch seemed to make more sense.

 function publication_date_field_formatter_info_alter(array &$info) {
   $info['timestamp']['field_types'][] = 'published_at';
   $info['timestamp_ago']['field_types'][] = 'published_at';
   $info['timestamp_ap_style']['field_types'][] = 'published_at';
 }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.