Back to vBulletin 3.5 Add-ons

Event Views Counter
Mod Version: 1.00, by robert_2004

This modification is in the archives.
vB Version: 3.5.4 Rating: (0 vote - 0 average) Installs: 3
Released: 04 Sep 2006 Last Update: Never Downloads: 0
Not Supported DB Changes Template Edits Code Changes  

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 with his post here

STEP 1 - MySQL modification:
Code:
ALTER TABLE event ADD hits INT(7) NOT NULL;
STEP 2 - calendar.php
FIND [line 134]
PHP Code:
($hook vBulletinHook::fetch_hook('calendar_start')) ? eval($hook) : false;

if (
$vbulletin->GPC['week'])
{
    
$_REQUEST['do'] = 'displayweek';

BELOW, ADD:
PHP Code:
// Event Views Counter - by Robert_2004
// index.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:
Code:
    </td>
</tr>
</table>
</form>
</div>
$spacer_close
BEFORE THIS, ADD:
Code:
    </td>
</tr>
<tr>
    <td>
    <!-- // Event Views Counter - by Robert_2004 -->
    <!-- // index.php?t=1067471 -->
    <strong>Viewed</strong>: $eventinfo[hits] times
so it should look like:
Code:
    </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

Download

No files for download.

Screenshots

 

Similar Mods

Forum Home Enhancements Forum Views Counter - Track the number of forum views Modification Graveyard
Profile Views Counter vBulletin 2.x Full Releases

vblts.ru supports vBulletin®, 2022-2024