MyBB Community Forums

Full Version: Announcements - how many views?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I'm wondering if there's a way to see how many views an announcement gets...can anyone help?

Thanks,

olly
Hi,

I'm afraid MyBB doesn't keep track of how many users view announcements by default. It would require a code modification.
(2008-07-03, 01:05 PM)Chris Wrote: [ -> ]Hi,

I'm afraid MyBB doesn't keep track of how many users view announcements by default. It would require a code modification.

Thanks.

Is there anywhere to add this as a feature request?
Am I better attempting this myself or is this feature likely to appear?
Open forumdisplay.php
Find following:
$posttime = my_date($mybb->settings['timeformat'], $announcement['startdate']);

After add following:
$annviews = my_number_format($announcement['views']);

Open announcements.php
Find following:
$lang->forum_announcement = sprintf($lang->forum_announcement, $announcementarray['subject']);

After add following:
$db->query("UPDATE ".TABLE_PREFIX."announcements SET views=views+1 WHERE aid='$aid'");

Go to AdminCP
Templates => Modify/Delete => Expand Your Template => Forum Display Templates => forumdisplay_announcements_announcement

Find following:
<td align="center" class="{$bgcolor}">-</td>
<td align="center" class="{$bgcolor}">-</td>

Replace with following:
<td align="center" class="{$bgcolor}">-</td>
<td align="center" class="{$bgcolor}">{$annviews}</td>

And then run following query in phpmyadmin:
ALTER TABLE `mybb_announcements` ADD `views` INT( 10 ) NOT NULL DEFAULT '0';

Note:If you don't use default db prefix(mybb_), you should change prefix with yours.
I don't see any strong point from adding views to announcement..
but you have made a good instoruction DragonFever.. thanks mate.
No problem buddy. It is unnecessary for me too but he wanted it and i wrote the instructions.
(2008-07-03, 07:15 PM)DragonFever Wrote: [ -> ]No problem buddy. It is unnecessary for me too but he wanted it and i wrote the instructions.

Thanks very much, will try this out and let you know how I get on.

I think it's useful to be able to track how many people are reading announcements as you can't assume that everyone in the forum does. Also, announcements don't show up on View New Posts. (Not a feature request Smile )

olly