vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   Event Views Counter (https://vborg.vbsupport.ru/showthread.php?t=125748)

robert_2004 09-03-2006 10:00 PM

Event Views Counter
 
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
// 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:
Code:

    </td>
</tr>
</table>

</form>

</div>
$spacer_close

BEFORE THIS, ADD:
Code:

    </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:
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

hugh_ 09-04-2006 10:41 AM

Can we see a screenshot or example?

Thanks...

hugh

robert_2004 09-05-2006 03:13 AM

screenshot added to orginal post.
It doesn't help much - as my event listing template is modified a great deal.

finn snor 09-06-2006 06:17 AM

Great have been looking for this for a long time..Can it be made conditional so only admin can see views ?

robert_2004 09-06-2006 04:08 PM

Yes, to only allow certain usergroups, use the following code:

usergroups 6 and 5 are admin and super moderators, respectively.


Code:

<if condition="is_member_of($bbuserinfo, 6, 5) OR $show['admincplink']">
<tr>
        <td>
        <strong>Viewed</strong>: $eventinfo[hits] times       
        </td>
</tr>
</if>


snowname 11-26-2013 03:06 AM

The database function works on 4.1.3.


All times are GMT. The time now is 03:44 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01241 seconds
  • Memory Usage 1,734KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete