Hi,

As I use alot of node types as forum topics, it would be nice to alter the display of the topic icon. I want to customize it and add my own topic icon, so you can easily see the difference between a poll and a forum topic for example. However, this takes alot of time to do it with a custom module, but would easily be achieved if this would get into the advanced forum module. The cahnges are easy:

1) add the following line to advanced_forum/includes/views/advanced_forum_handler_field_node_topic_icon.inc

<?php
/**
* @file
* Field handler to display the topic icon.
*/
class advanced_forum_handler_field_node_topic_icon extends views_handler_field{
  function
construct() {
   
parent::construct();
   
$this->additional_fields = array('nid' => 'nid', 'type' => 'type');
  }
  function
option_definition() {
   
$options = parent::option_definition();
   
$options['hot_topic_threshold'] = array('default' => 15);
    return
$options;
  }
  function
options_form(&$form, &$form_state) {
   
parent::options_form($form, $form_state);
   
$form['hot_topic_threshold'] = array(
     
'#title' => t('Hot topic threshold'),
     
'#description' => t('The number of posts a topic must have to be considered "hot".'),
     
'#type' => 'textfield',
     
'#default_value' => $this->options['hot_topic_threshold'],
    );
  }
  function
query() {
   
$this->ensure_my_table();
   
$this->add_additional_fields();
   
$this->field_alias = $this->table . '_' . $this->field;
  }
  function
render($values) {
   
$new_posts = advanced_forum_reply_num_new($values->nid);
    return
theme('forum_icon', array(
     
'new_posts' => $new_posts,
     
'num_posts' => empty($values->node_comment_statistics_comment_count) ? 1 : $values->node_comment_statistics_comment_count + 1,
     
'comment_mode' => $values->node_comment,
     
'sticky' => $values->node_sticky,
     
'node_type' => $values->node_type, // This one is new
   
));
  }
}
?>

You can now already override the template file of advanced forum in the theme directory, or could completely overwrite it with the following:

<?php
/**
* @file
* Display an appropriate icon for a forum post.
*
* Available variables:
* - $new_posts: Indicates whether or not the topic contains new posts.
* - $icon: The icon to display. May be one of 'hot', 'hot-new', 'new',
*   'default', 'closed', or 'sticky'.
* - $node_type: The type of the node that is displayed
*
* @see template_preprocess_forum_icon()
* @see advanced_forum_preprocess_forum_icon()
*/
?>

<?php if ($new_posts): ?>
  <a name="new">
<?php endif; ?>
<?php if (!empty($icon_class)): ?>
<span class="<?php print "topic-icon topic-icon-$icon_class topic-icon-node-type-$node_type"; ?>"><?php print "$icon_title"; ?></span>
<?php endif; ?>
<?php if ($new_posts): ?>
  </a>
<?php endif; ?>

Comments

Status:Active» Fixed

Looking good. Committed to 7.x-dev
Thanks.

Status:Fixed» Closed (fixed)

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

Issue summary:View changes

Put template into code tags