2009-07-28, 01:53 AM
(This post was last modified: 2009-07-28, 10:50 AM by Theberge43.)
Hi, I would like to tweak the code to imitate a feature I like from PHPBB3.
On the index page, when a forum has an unread post, not only does the icon changes, but the color of the link as well.
Here is the function we'll probably need to tweak MyBB\inc\functions_forumlist.php:
In the PHPBB template system they just changed the class of the link. Which is something we could do with a new variable in the template of MyBB. Since my PHP knowledge is very limited, I'd like some help !
----------
Well ... it just hit me in the face when I woke up this morning !
No changes to the .php code, juste template and CSS.
Template :
CSS
Maybe a mod could move the topic to the Styles section ?
On the index page, when a forum has an unread post, not only does the icon changes, but the color of the link as well.
Here is the function we'll probably need to tweak MyBB\inc\functions_forumlist.php:
function get_forum_lightbulb($forum, $lastpost, $locked=0)
{
global $mybb, $lang, $db, $unread_forums;
// This forum is closed, so override the folder icon with the "offlock" icon.
if($forum['open'] == 0 || $locked)
{
$folder = "offlock";
$altonoff = $lang->forum_locked;
}
else
{
// Fetch the last read date for this forum
if($forum['lastread'])
{
$forum_read = $forum['lastread'];
}
else
{
$forum_read = my_get_array_cookie("forumread", $forum['fid']);
}
if(!$forum_read)
{
$forum_read = $mybb->user['lastvisit'];
}
// If the lastpost is greater than the last visit and is greater than the forum read date, we have a new post
if($lastpost['lastpost'] > $forum_read && $lastpost['lastpost'] != 0)
{
$unread_forums++;
$folder = "on";
$altonoff = $lang->new_posts;
}
// Otherwise, no new posts
else
{
$folder = "off";
$altonoff = $lang->no_new_posts;
}
}
return array(
"folder" => $folder,
"altonoff" => $altonoff
);
}
In the PHPBB template system they just changed the class of the link. Which is something we could do with a new variable in the template of MyBB. Since my PHP knowledge is very limited, I'd like some help !
<a class="forumlink<!-- IF forumrow.S_UNREAD_FORUM --> link-new<!-- ENDIF -->" href="{forumrow.U_VIEWFORUM}">{forumrow.FORUM_NAME}</a>
----------
Well ... it just hit me in the face when I woke up this morning !
No changes to the .php code, juste template and CSS.
Template :
<tr>
<td class="{$bgcolor}" align="center" valign="middle" width="1">
<img src="{$theme['imgdir']}/{$lightbulb['folder']}.gif" alt="{$lightbulb['altonoff']}" title="{$lightbulb['altonoff']}" class="ajax_mark_read" id="mark_read_{$forum['fid']}" /></td>
<td class="{$bgcolor}" valign="middle">
<a class="{$lightbulb['folder']}_link" href="{$forum_url}">{$forum['name']}</a>
<div class="smalltext">
{$forum['description']}{$modlist}{$subforums}
</div>
</td>
<td class="{$bgcolor}" valign="middle" align="left" style="white-space: nowrap" width="125">
<div>
{$threads}{$unapproved['unapproved_threads']} {$lang->forumbit_threads}
<br />
<div class="smalltext">
{$posts}{$unapproved['unapproved_posts']} {$lang->forumbit_posts}
</div>
</div>
<td class="{$bgcolor}" valign="middle" align="left" style="white-space: nowrap" width="250">{$lastpost}</td>
</tr>
CSS
a.on_link, a.on_link:visited {
color: #FF3200;
}
Maybe a mod could move the topic to the Styles section ?