User login

Ask Agaric (unsolicited edition) - how to change Drupal core output with a theme

Hi Neil,

I haven't themed forums in this way but here's the general approach:

You want to look in forum.module (and possibly other files such as include/*.inc files-- core isn't entirely modular (yet) to try to find the function that outputs the time. It _should_ be named function theme_something_something. (Where it is actually called to produce output it will be in the form theme('something_something') -- this is how Drupal allows you to override theme functions rather than modify core.

You don't modify forum.module, you will want to copy that function, paste it in a template.php file for your theme, and rename it mythemename_ or phptemplate_something_something, and modify it here.

I'm not saying it won't get more complicated than this ( for instance, you don't want to retheme something like theme_item_list because that will change the display all over your web site, so you need to look for a more specific theme_ function that calls theme_item_list ) but that's the Drupal way there.

benjamin, Agaric Design Collective, http://AgaricDesign.com/

On Nov 5, 2007 7:07 PM, Neil wrote:

I have a lot of work to do on node-forum.tpl.php and comment.tpl.php in an
attempt to get a nice fresh look to my forums.

I have a few specific questions, but don't want to swamp everyone so will
just begin with what is hopefully quite a simple one:

on the forum listing page (where you actually have the threads listed out),
both the Created and Last Reply columns have the date in "Time Ago" format.
How can I alter this to be an actual date? I presume I would need to go into
the forum.module file, is that correct?

Thanks in advance

Neil

[ Drupal support list | http://lists.drupal.org/ ]

Resolution

Comments

function

function theme_forum_topic_list is the theme you're looking for.

Copy it into template.php and name it phptemplate_forum_topic_list and you'll be able to override it.

I imagine the part you want to change is here:
array('data' => _forum_format(isset($topic->last_reply) ?

benjamin, Agaric Design Collective, http://AgaricDesign.com/

On Nov 6, 2007 9:44 AM, Neil wrote:

I have found this in the forum.module:

/**
* Format the topic listing.
*
* @ingroup themeable
*/
function theme_forum_topic_list($tid, $topics, $sortby, $forum_per_page) {
global $forum_topic_list_header;
$rows = array();
if ($topics) {

foreach ($topics as $topic) {
// folder is new if topic is new or there are new comments since last

visit
if ($topic->tid != $tid) {
$rows[] = array(
array('data' => theme('forum_icon', $topic->new,
$topic->num_comments, $topic->comment_mode, $topic->sticky), 'class' =>
'icon'),
array('data' => check_plain($topic->title), 'class' => 'title'),
array('data' => l(t('This topic has been moved'),
"forum/$topic->tid"), 'colspan' => '3')
);
}
else {
$rows[] = array(
array('data' => theme('forum_icon', $topic->new,
$topic->num_comments, $topic->comment_mode, $topic->sticky), 'class' =>
'icon'),
array('data' => l($topic->title, "node/$topic->nid"), 'class' =>
'topic'),
array('data' => $topic->num_comments . ($topic->new_replies ? '
'. l(format_plural($topic->new_replies, '1 new', '@count new'),
"node/$topic->nid", NULL, NULL, 'new') : ''), 'class' => 'replies'),
array('data' => _forum_format($topic), 'class' => 'created'),
array('data' => _forum_format(isset($topic->last_reply) ?
$topic->last_reply : NULL), 'class' => 'last-reply')
);
}
}
}

$output = theme('table', $forum_topic_list_header, $rows);
$output .= theme('pager', NULL, $forum_per_page, 0);

return $output;

}

But I can't find the forum_topic_list theme anywhere in my drupal files.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.