Odd and Even Forums and Hot Icons for PunBB

PunBB adds classes for odd and even posts, but not for odd and even forum rows. PunBB also adds several classes for icons we can tap into, but there is no way to know if a topic is “hot”. Let’s add a hack that will mark any topic that has more than 25 posts as “hot” and setup odd and even forum rows.

Open up viewforum.php

Find this line

// If there are topics in this forum.
if ($db->num_rows($result))
{

And add this afterwards

$temp_counter = 0;

Then find this line

// Should we show the "New posts" and/or the multipage links?
if (!empty($subject_new_posts) || !empty($subject_multipage))
{
$subject .= '  '.(!empty($subject_new_posts) ? $subject_new_posts : '');
$subject .= !empty($subject_multipage) ? ' '.$subject_multipage : '';
}

And add this afterwards

$temp_counter++;

Then find this line

<tr<?php if ($item_status != '') echo ' class="'.trim($item_status).'"'; ?>>

And modify it to be this instead

<tr class="<?php
/*MODIFIED*/
if ($temp_counter % 2)
echo 'forum_rowodd';
else
echo 'forum_roweven';
//hoticon
$temp_status = trim($item_status);
if (($cur_topic['num_replies'] > 25) && ($temp_status == '' || $temp_status == 'inew'))
{
if ($temp_status == '')
echo ' ihot';
else
echo ' ihot_inew';
}
else if ($item_status != '')
echo ' '.trim($item_status);
/*MODIFIED END*/ ?>">

Now for CSS

/*style rows*/
tr.forum_rowodd {background-color:#eee;}
tr.forum_rowodd td.tc2, tr.forum_rowodd td.tc3 {background-color:#ddd;}
tr.forum_roweven {background-color:#ccc;}
tr.forum_roweven td.tc2, tr.forum_roweven td.tc3 {background-color:#bbb;}
/*style hot and hot new posts*/
tr.ihot div.icon {background-image:url(../../img/hot.png);}
tr.ihot_inew div.icon {background-image:url(../../img/hot_new.png);}
/*css we used for icons before*/
div.icon {
float:left;
display:block;
width:28px;
height:25px;
background-repeat:no-repeat;
background-position:center center;
border:0 !important;
}
/*if you aren't using any images you can use something like this
tr.ihot DIV.icon {BORDER-COLOR: #600 #700 #800 #900}
tr.ihot_inew DIV.inew {BORDER-COLOR: #006 #007 #008 #009}
*/

I updated code the code, since I didn’t like how it was before

Tags: ,

Leave a Comment

Comments are reviewed before publishing to prevent spam.