need help on post date display

giorez - November 7, 2008 - 21:37
Project:Tribune
Version:6.x-2.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

the module works great, but a bit confusing. I'd need to show also the date (day/month) in front of the post time

#1

SeeSchloss - November 17, 2008 - 12:07
Version:6.x-1.5» 6.x-1.6
Status:active» postponed (maintainer needs more info)

Okay so I've changed most of the code to use theme functions now, so you could just implement in your theme a function like this for example :

<?php
function garland_post_time($post) {
   
$contents  = "<span class='tribune-first-clock' title='id=". $post['id'] ."'>";
   
$contents .= date('H:i d/m/Y', tribune_date_to_timestamp(tribune_date_to_localdate($post['post_time'])));
   
$contents .= "</span>\n";
    return
$contents;
}
?>

This displays post time as "13:07 17/11/2008". Of course, post matching with clocks will not work as well, though, unless you include $post['clock'] somewhere.

Please tell me if it worked :)

#2

giorez - November 17, 2008 - 22:57

sorry, I feel so stupid, but I don't know where tu put

<?php
function garland_post_time($post) {
   
$contents  = "<span class='tribune-first-clock' title='id=". $post['id'] ."'>";
   
$contents .= date('H:i d/m/Y', tribune_date_to_timestamp(tribune_date_to_localdate($post['post_time'])));
   
$contents .= "</span>\n";
    return
$contents;
}
?>

and this

$post['clock']

#3

SeeSchloss - November 18, 2008 - 18:44

What theme are you using?

There should be a file called template.php in your theme's directory (if it doesn't exist, I think you should just create it), append this code to it:

<?php
function phptemplate_post_time($post) {
   
$timestamp = tribune_date_to_timestamp(tribune_date_to_localdate($post['post_time']));

   
$contents  = "<span class='tribune-first-clock' title='id=". $post['id'] ."'>";
   
$contents .= date('H:i d/m/Y', $timestamp);
   
$contents .= "</span>\n";

    return
$contents;
}
?>

... there are howtos and documentation about overriding theme functions in Drupal.org handbooks, but I can't look for them now.

This template.php file should be located in <site root>/themes/<theme name>/template.php, I think

#4

giorez - November 19, 2008 - 00:58

I appended the function in /themes/deco/template.php
but I got following error
Fatal error: Call to undefined function get_last_posts() in /sites/all/modules/tribune/tribune.page.inc on line 62

any idea? thanks a lot for your help

#5

SeeSchloss - November 19, 2008 - 14:18

Hmm, are you sure you haven't touched anything other than your theme's template.php file? Because in no way could this cause this problem... maybe you should try to download the latest version and replace all the files in your modules/tribune folder.

#6

giorez - November 19, 2008 - 21:35

I double checked also with tribune 1.8, now I don't get any error, but nothing changes with the time printed in front of each message (no date printing in front of time)

#7

giorez - November 19, 2008 - 22:37

I solved the problem (on tribune 1.8) hacking the tribune.mudule file at line #816

function theme_post_time($post) {
$timestamp = tribune_date_to_timestamp(tribune_date_to_localdate($post['post_time'])); //gio inserito riga - new line added
$contents = "";
// $contents .= $post['clock']; // gio eliminato riga - deleted line
$contents .= date('jM H:i', $timestamp); // gio inserito riga - new line added
$contents .= "\n";

return $contents;
}

#8

SeeSchloss - November 20, 2008 - 10:02
Status:postponed (maintainer needs more info)» fixed

Well, I suppose it's fine then... doing it with a theme override would have prevented problems when updating the module, though

#9

System Message - December 4, 2008 - 10:05
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

#10

giorez - June 30, 2009 - 21:25
Version:6.x-1.6» 6.x-2.x-dev
Status:closed» active

how do I add year/month/day to hour/minute/second related to the post-time in tribune?
the previous hack is not working anymore with 2.x-dev version.
any help is apprecciated

 
 

Drupal is a registered trademark of Dries Buytaert.