You are here

function publication_date_render_published_at_field in Publication Date 7.2

Same name and namespace in other branches
  1. 8 publication_date.ds_fields_info.inc \publication_date_render_published_at_field()

Render the publication date field.

See also

publication_date_ds_fields_info()

1 string reference to 'publication_date_render_published_at_field'
publication_date_ds_fields_info in ./publication_date.ds_fields_info.inc
Implements hook_ds_fields_info().

File

./publication_date.ds_fields_info.inc, line 44
Display Suite Integration.

Code

function publication_date_render_published_at_field($field) {
  $date_format = str_replace('publication_date_', '', $field['formatter']);
  if (isset($field['entity']->published_at) && !empty($field['entity']->published_at)) {
    return format_date($field['entity']->published_at, $date_format);
  }
  else {

    // If the entity has never been published, then return the current time.
    return format_date(time(), $date_format);
  }
}