robert_2004
09-03-2006, 10:00 PM
This addon allows you to display the number of hits/views a calendar event has received.
It also inserts the eventid into the user's session, so they cannot refresh multiple times to boost the view count.
Thanks to tnguy3n (https://vborg.vbsupport.ru/member.php?u=35159) with his post here (https://vborg.vbsupport.ru/showthread.php?t=78527)
STEP 1 - MySQL modification:
ALTER TABLE event ADD hits INT(7) NOT NULL;
STEP 2 - calendar.php
FIND [line 134]
($hook = vBulletinHook::fetch_hook('calendar_start')) ? eval($hook) : false;
if ($vbulletin->GPC['week'])
{
$_REQUEST['do'] = 'displayweek';
}
BELOW, ADD:
// Event Views Counter - by Robert_2004
// https://vborg.vbsupport.ru/showthread.php?t=1067471
/*
* Comparision done between the host info in the session object.
* If the eventid is not stored in the session, that means the
* event hasn't been visited and therefore add it as a hit
* and update the table.
*/
$_SESSION['eventidsvisited'] = isset($_SESSION['eventidsvisited'])?$_SESSION['eventidsvisited']:array();
$eventids_exists = array_search($vbulletin->GPC['eventid'], $_SESSION['eventidsvisited']);
if ( $eventids_exists == 0) {
$_SESSION['eventidsvisited'][] = $vbulletin->GPC['eventid'];
$db->query_write("
UPDATE " . TABLE_PREFIX . "event
SET hits=hits+1
WHERE eventid=" . $vbulletin->GPC['eventid']);
}
Save and upload.
STEP 3 - template modification
edit template "calendar_showeventsbit"
FIND:
</td>
</tr>
</table>
</form>
</div>
$spacer_close
BEFORE THIS, ADD:
</td>
</tr>
<tr>
<td>
<!-- // Event Views Counter - by Robert_2004 -->
<!-- // https://vborg.vbsupport.ru/showthread.php?t=1067471 -->
<strong>Viewed</strong>: $eventinfo[hits] times
so it should look like:
</td>
</tr>
<tr>
<td>
<strong>Viewed</strong>: $eventinfo[hits] times
</td>
</tr>
</table>
</form>
</div>
$spacer_close
and that *should* be everything - i can't think of anything else that was needed.
if you use - please click INSTALL
It also inserts the eventid into the user's session, so they cannot refresh multiple times to boost the view count.
Thanks to tnguy3n (https://vborg.vbsupport.ru/member.php?u=35159) with his post here (https://vborg.vbsupport.ru/showthread.php?t=78527)
STEP 1 - MySQL modification:
ALTER TABLE event ADD hits INT(7) NOT NULL;
STEP 2 - calendar.php
FIND [line 134]
($hook = vBulletinHook::fetch_hook('calendar_start')) ? eval($hook) : false;
if ($vbulletin->GPC['week'])
{
$_REQUEST['do'] = 'displayweek';
}
BELOW, ADD:
// Event Views Counter - by Robert_2004
// https://vborg.vbsupport.ru/showthread.php?t=1067471
/*
* Comparision done between the host info in the session object.
* If the eventid is not stored in the session, that means the
* event hasn't been visited and therefore add it as a hit
* and update the table.
*/
$_SESSION['eventidsvisited'] = isset($_SESSION['eventidsvisited'])?$_SESSION['eventidsvisited']:array();
$eventids_exists = array_search($vbulletin->GPC['eventid'], $_SESSION['eventidsvisited']);
if ( $eventids_exists == 0) {
$_SESSION['eventidsvisited'][] = $vbulletin->GPC['eventid'];
$db->query_write("
UPDATE " . TABLE_PREFIX . "event
SET hits=hits+1
WHERE eventid=" . $vbulletin->GPC['eventid']);
}
Save and upload.
STEP 3 - template modification
edit template "calendar_showeventsbit"
FIND:
</td>
</tr>
</table>
</form>
</div>
$spacer_close
BEFORE THIS, ADD:
</td>
</tr>
<tr>
<td>
<!-- // Event Views Counter - by Robert_2004 -->
<!-- // https://vborg.vbsupport.ru/showthread.php?t=1067471 -->
<strong>Viewed</strong>: $eventinfo[hits] times
so it should look like:
</td>
</tr>
<tr>
<td>
<strong>Viewed</strong>: $eventinfo[hits] times
</td>
</tr>
</table>
</form>
</div>
$spacer_close
and that *should* be everything - i can't think of anything else that was needed.
if you use - please click INSTALL