Hi
Need some help.
I want to insert a new column into the topic list table to show Topic views count. Got some code working, but I have a problem with the table headings.
In template_preprocess_forum_topic_list(&$variables) in D6_compat.inc, I see the headings are in the $forum_topic_list_header array. But this array is made in the core forum.module:

$forum_topic_list_header = array(
    array('data' => ' ', 'field' => NULL),
    array('data' => t('Topic'), 'field' => 'n.title'),
    array('data' => t('Replies'), 'field' => 'l.comment_count'),
    array('data' => t('Created'), 'field' => 'n.created'),
    array('data' => t('Last reply'), 'field' => 'l.last_comment_timestamp'),
);

I want to insert another heading into it:

$forum_topic_list_header = array(
    array('data' => ' ', 'field' => NULL),
    array('data' => t('Topic'), 'field' => 'n.title'),
    array('data' => t('Replies'), 'field' => 'l.comment_count'),
    array('data' =>t('Views'), 'field' =>'l.topic_views',   //<<<<insert here
    array('data' => t('Created'), 'field' => 'n.created'),
    array('data' => t('Last reply'), 'field' => 'l.last_comment_timestamp'),
);

How would I do that without having to change code in the core module?

Comments

Max_Headroom’s picture

Status: Active » Fixed

Late nights and me thinking I want to do things right by the book.
I've just put the whole thing over into D6_compat.inc and changed the array name.

Michelle’s picture

Title: How to override forum code » Adding number of views to topic list
Category: support » feature
Status: Fixed » Active

This is actually on my to do list. Adding it to the d6_compat file isn't the way to go. What's in that file is in core in D6 so you'd have to hack core to do the same thing once you move. Care to share your code for getting the views? That would give me a head start on doing this. I'm hoping to get back to the module in the next couple days. Just been very busy.

Michelle

Max_Headroom’s picture

Hi Michelle
Where would you suggest I put it? In the d6_compat file is all the code needed to do table sorting.

There is an easy way to do views, but that requires the the statistics module to be enabled. I am currently working on something that does not require that module. Will put it up as soon as I get it to work.

Michelle’s picture

I'm ok with requiring statistics for it. That's a core module so not an extra download.

I'll have to look to figure out how best to handle adding to the table. It will likely be a few days so, if you're in a hurry, go ahead and do whatever you need to make it work. But I need to be more careful when it comes to what actually goes in the module.

Michelle

Michelle’s picture

Status: Active » Closed (duplicate)

http://drupal.org/node/242527 has some code so marking this one a dupe.

Michelle