Drupal Tip #7: Use Custom Thread Icons

Want new and shiny icons for your Drupal forum? Follow that guide! For pressed persons, the ZIP file containing the icons is at the end of this article.

As you know, it is not recommend to modify the core package of Drupal, and therefore, you are not supposed to modify the misc/ folder as well. Starting from this point, how could you now modify the images of the thread icons, to let them being more modern? This is what we are going to explain here.

Forum Thread Icons Screenshot

Even if you can't modify the Drupal core files, you can however customize an existing template file that is part of the Drupal Forum module: forum-icon.tpl.php. To customize it, as usual, create this file in your theme folder, and clear the Drupal cache. Now, Drupal will use this new file instead of the default one.

  1. Here is the content of the new file, that will relocate the default path of icons:

    forum-icon.tpl.php

     <?php
     // $Id: forum-icon.tpl.php,v 1.3 2007/12/20 09:35:09 goba Exp $
     
     /**
      * @file forum-icon.tpl.php
      * 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', 'clost', or 'sticky'.
      *
      * @see template_preprocess_forum_icon()
      * @see theme_forum_icon()
      */
     ?>
     <?php 
      $title = $icon;
      if ($title == "default") {
       $title = "post";
      }
     
     ?>
     <img src="<?php print forum_thread_icon_path() . "/forum/forum-$icon.png"; ?>" alt="<?php print $icon; ?>" title="<?php print ucfirst($title); ?>" />

    Note that we also support the title attribute, to let user know the meaning of each icon.

  2. As you can see, we have created a new function, called forum_thread_icon_path(), and you now just need to define it to return the folder where you want to store the icons:

    template.php

    function forum_thread_icon_path() {
      return "/sites/default/theme/mytheme/images";
    }

Custom Thread Icons Package

And as promise, here is the archive containing the forum thread icons. Download this file, and put its content to the path you defined in your forum_thread_icon_path() function.

Note that this icons have been designed by Yoroy, and should be present by default in Drupal 7.

Keywords:
Post a Comment

Comments (6)

Those look an awful lot like

Those look an awful lot like the icons from Drupal 7 created by yoroy as seen here:

http://drupal.org/node/102743#comment-1219859

Michelle

Top
lastnico's picture

Absolutely! Do you mean that

Absolutely! Do you mean that I should cite my source? You're right, and that's done. Thank you.

FSR Admin - Vote for 2012.

Top

Well, should probably isn't

Well, should probably isn't the right word. They are GPL and it's not required. But the original post implied that they were something you made by omitting the credit so I think it's good that you give credit to the maker.

If you use Advanced Forum, these are the icons you get by default and I credit yoroy in the readme.

Michelle

Top
lastnico's picture

Yes, I knew it was used in

Yes, I knew it was used in Advanced Forum as well. And I absolutely agree with you, not giving credit is unfair for the original author. About that, did he officially post them as GPL?

FSR Admin - Vote for 2012.

Top

Yes, everything in the

Yes, everything in the drupal.org repository has to be GPL.

Michelle

Top
lastnico's picture

Thanks for the info.

Thanks for the info.

FSR Admin - Vote for 2012.

Top

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <img> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <html>.
  • You may quote other posts using [quote] tags.
  • Textual smileys will be replaced with graphical ones.

More information about formatting options

  Top Top