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.
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.
-
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.
-
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.
Comments (9)
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
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.
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
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.
Well folks, I guess you
Well folks, I guess you should think about changing a comment system, am I right? Or at least moderate the comments. Anyways I wanted to say that I liked this post on Facebook.
sms birthday
Yes, everything in the
Yes, everything in the drupal.org repository has to be GPL.
Michelle
Thanks for the info.
Thanks for the info.
FSR Admin - Vote for 2012.
do i need to edit
do i need to edit template.php also for the changes to take affect
Also tell me
which path do i need to define
This is a great tutorial,
This is a great tutorial, however I have one question. If we wanted custom icons for several different levels, say all of Yoroy's icons for "generic" forums, but specific icons for specialized forums that also include the 'lock' 'hot', 'hotnew' 'new, etc.. How would we go about this using this method? Or to rephrase, how would we include additional icons for selection?
Any help would be greatly appreciated