ProsePoint Express: hosted newspaper website content management software

Would like to see ability to display am/pm as a.m./p.m.

  • strict warning: Non-static method view::load() should not be called statically in /home/prosepoint.org/bzr/public_html/profiles/prosepoint/modules/views/views.module on line 879.
  • strict warning: Declaration of views_handler_argument::init() should be compatible with views_handler::init(&$view, $options) in /home/prosepoint.org/bzr/public_html/profiles/prosepoint/modules/views/handlers/views_handler_argument.inc on line 0.
  • strict warning: Declaration of views_handler_filter::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /home/prosepoint.org/bzr/public_html/profiles/prosepoint/modules/views/handlers/views_handler_filter.inc on line 0.
  • strict warning: Declaration of views_handler_filter::options_submit() should be compatible with views_handler::options_submit($form, &$form_state) in /home/prosepoint.org/bzr/public_html/profiles/prosepoint/modules/views/handlers/views_handler_filter.inc on line 0.
  • strict warning: Declaration of views_handler_filter_node_status::operator_form() should be compatible with views_handler_filter::operator_form(&$form, &$form_state) in /home/prosepoint.org/bzr/public_html/profiles/prosepoint/modules/views/modules/node/views_handler_filter_node_status.inc on line 0.
  • strict warning: Non-static method view::load() should not be called statically in /home/prosepoint.org/bzr/public_html/profiles/prosepoint/modules/views/views.module on line 879.
  • strict warning: Declaration of views_handler_filter_boolean_operator::value_validate() should be compatible with views_handler_filter::value_validate($form, &$form_state) in /home/prosepoint.org/bzr/public_html/profiles/prosepoint/modules/views/handlers/views_handler_filter_boolean_operator.inc on line 0.
  • strict warning: Declaration of date_api_filter_handler::value_validate() should be compatible with views_handler_filter::value_validate($form, &$form_state) in /home/prosepoint.org/bzr/public_html/profiles/prosepoint/modules/date/includes/date_api_filter_handler.inc on line 0.
  • strict warning: Non-static method view::load() should not be called statically in /home/prosepoint.org/bzr/public_html/profiles/prosepoint/modules/views/views.module on line 879.
  • strict warning: Declaration of views_plugin_row::options_validate() should be compatible with views_plugin::options_validate(&$form, &$form_state) in /home/prosepoint.org/bzr/public_html/profiles/prosepoint/modules/views/plugins/views_plugin_row.inc on line 0.
  • strict warning: Declaration of views_plugin_row::options_submit() should be compatible with views_plugin::options_submit(&$form, &$form_state) in /home/prosepoint.org/bzr/public_html/profiles/prosepoint/modules/views/plugins/views_plugin_row.inc on line 0.
5 replies [Last post]
News_designer
User offline. Last seen 6 years 40 weeks ago. Offline
Joined: 10/01/2010
Posts:

I am currently working on a test site in preparation for building a new site for the newspaper where i work. I have created a "Time" field for stories, so that each story displays (in the story page and in the teaser) the time that the story was created or last updated.

However, I would like to be able to display the time with the proper AP style: a.m. and p.m. instead of the PHP default of am and pm (or AM and PM).

I've been researching the problem online; I discovered that someone wrote a plug-in for WordPress; here is part of the code:

function ap_time() {
$capnoon = get_option('ap_capnoon');

// Format am and pm to AP Style abbreviations

if (get_the_time('a')=='am') :
$meridian = 'a.m.';
elseif (get_the_time('a')=='pm') :
$meridian = 'p.m.';
endif;

// Reformat 12:00 and 00:00 to noon and midnight

if (get_the_time('H:i')=='00:00') :
if ($capnoon == "true") :
$aptime = "Midnight";
else :
$aptime = "midnight";
endif;

elseif (get_the_time('H:i')=='12:00') :
if ($capnoon == "true") :
$aptime = "Noon";
else :
$aptime = "noon";
endif;

// Eliminate trailing zeroes from times at the top of the hour and set final output

elseif (get_the_time('i')=='00') :
$aptime = get_the_time('g')." ".$meridian;
else :
$aptime = get_the_time('g:i')." ".$meridian;
endif;

echo $aptime;
}

I would love to find a way to implement this for my site in ProsePoint, even if it means hacking the Date API.

 

__________________

Katrina
Digital media designer and webmaster for a small daily newspaper
www.courier-tribune.com

beng
User offline. Last seen 4 years 30 weeks ago. Offline
Joined: 27/02/2009
Posts:
There is already a created and a changed timestamp

Hi,

> the time that the story was created or last updated.

Actually, you didn't need to create a custom field for this. There is already a created and a changed timestamp for all nodes, just that it is not shown by default. To get it the way you want would likely require a little bit of custom themeing.

As for showing time in AP style ... I think this will also require some custom code. Is this just for the created and changed timestamps of story nodes, or for other date/time values elsewhere in the site?

I think I can help you some more, but I need a bit of clarification first.

News_designer
User offline. Last seen 6 years 40 weeks ago. Offline
Joined: 10/01/2010
Posts:
"Time" field

It was easier for me to create a custom Time field, rather than having to delve into the theme. You can see the end result on my test site: http://localnews.polestarstudios.com/

Also, having a custom Time field allows the time in that field to be set to a certain time, since we'll be using editions to post stories at certain times on certain days. (Which means that the time that the story is actually available to the end user will not be the same as the time when the story was created or last modified.)

Notice that each story has the time listed in dull red, so that readers know how "fresh" the story is.

That field is the one I'd like to dsiplay as "10:15 p.m." instead of "10:15 pm" in the teaser view and the full story view. I don't mind if PHP values on the "back end" of the site, that only editors and staff will see, are in default PHP style. But I would like for time values that the end users see to be in proper AP style.

Hopefully, that clarifies things; if not, let me know.

 

__________________

Katrina
Digital media designer and webmaster for a small daily newspaper
www.courier-tribune.com

beng
User offline. Last seen 4 years 30 weeks ago. Offline
Joined: 27/02/2009
Posts:
...

Hi,

Hmmm ... if you are using a CCK time field, then here are my comments.

The presentation of a CCK field is controlled by the configuration of CCK and/or its field type modules. The ideal, proper way to implement an AP style time format (or any other non-standard custom time format) for a CCK field would be to write a small add-on module that adds a new display option, maybe something called 'AP style', to the usual Long, Medium or Short date/time options. In the long run, this is the best approach for maintainability and clean code. However, this is a bit more involved at the beginning because it requires writing a custom module (albeit a fairly small one). If this was a site I was building for a client, this would be my recommendation.

The other approach is to hack the node-story*.tpl.php files in your subtheme to directly insert the necessary code to manipulate the CCK field of interest (which is a property of the object $node) into the time format you want. This is a direct contravention of Drupal coding principles and is generally not a good way to do things. However, it may be the quickest or most feasible approach from your point of view.

So, the question now, I guess, is which of these two approaches, if any, that you choose to go with.

News_designer
User offline. Last seen 6 years 40 weeks ago. Offline
Joined: 10/01/2010
Posts:
String override worked

Well, I'd posted this same question to a forum on the Drupal site, and after a LOT of wrangling about with other possibilities (most of which were based on the assumption that I was using the "changed" timestamp within the node and not a user-imposed timestamp; that misunderstanding caused a lot of problems), someone finally came up with a very workable solution using the String overrides module:

Change !ampm-abbreviation am|pm|AM|PM to !ampm-abbreviation a.m.|p.m.|A.M.|P.M. .

Voila! Problem solved.

__________________

Katrina
Digital media designer and webmaster for a small daily newspaper
www.courier-tribune.com

beng
User offline. Last seen 4 years 30 weeks ago. Offline
Joined: 27/02/2009
Posts:
Oh good. Issue resolved then.

Oh good. Issue resolved then.