Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases

Reply
 
Thread Tools
Number of views per announcement Details »»
Number of views per announcement
Version: 1.00, by Zzed Zzed is offline
Developer Last Online: Feb 2012 Show Printable Version Email this Page

Version: 2.2.x Rating:
Released: 04-08-2002 Last Update: Never Installs: 7
 
No support by the author.

I wasn't able to find this hack anywhere. So I wrote this.

This hack will show the number of views per announcement.

Tables affected: announcement
Templates affected: forumdisplay_announcement
Files affected: forumdisplay.php and announcement.php

First we need to add a new field to announcement:

alter table announcement add visits smallint(5) unsigned DEFAULT 0 NOT NULL;

Then we need to modify forumdisplay_announcement template:

Look for the following:
Code:
<smallfont><br>($announcement[usertitle])</smallfont></td>
	<td bgcolor="#F1F1F1"><normalfont>-</normalfont></td>
	<td bgcolor="#DFDFDF"><normalfont>-</normalfont></td>
And replace it with the following:
Code:
<smallfont><br>($announcement[usertitle])</smallfont></td>
	<td bgcolor="#F1F1F1"><normalfont>-</normalfont></td>
	<td bgcolor="#DFDFDF"><normalfont>$announcement[visits]</normalfont></td>
In forumdisplay.php:

Look for the following:
PHP Code:
if ($announcement=$DB_site->query_first("SELECT announcementid,startdate,title,user.username,user.userid,user.usertitle,user.customtitle
                                         FROM announcement
                                         LEFT JOIN user
                                           ON user.userid=announcement.userid
                                         WHERE startdate<=
$datenow AND enddate>=$datenow
                                           AND 
$forumlist
                                         ORDER BY startdate DESC
                                         LIMIT 1"
)) {
    if (
$foruminfo[allowratings]) {
      
$thread[rating]='clear.gif';
      eval(
"\$threadrating = \"".gettemplate('forumdisplaybit_threadrate')."\";");
      
$backcolor '#DFDFDF';
          
$bgclass "alt2";
    } else {
                        unset(
$threadrating);
      
$backcolor '#F1F1F1';
          
$bgclass "alt1";
    }

     if (
$announcement[customtitle]==2)
       
$announcement[usertitle] = htmlspecialchars($announcement[usertitle]);
           
$announcement[postdate]=vbdate($dateformat,$announcement[startdate]);

  if (
$announcement[startdate]>$bbuserinfo[lastvisit]) {
        
$announcement[icon]='newannounce.gif';
  } else {
        
$announcement[icon]='announce.gif';
  }
  eval(
"\$announcement = \"".gettemplate('forumdisplay_announcement')."\";");
  
$doneannouncements 1;

And replace it with the following:
PHP Code:
if ($announcement=$DB_site->query_first("SELECT announcementid,startdate,title,user.username,user.userid,user.usertitle,user.customtitle,visits
                                         FROM announcement
                                         LEFT JOIN user
                                           ON user.userid=announcement.userid
                                         WHERE startdate<=
$datenow AND enddate>=$datenow
                                           AND 
$forumlist
                                         ORDER BY startdate DESC
                                         LIMIT 1"
)) {
    if (
$foruminfo[allowratings]) {
      
$thread[rating]='clear.gif';
      eval(
"\$threadrating = \"".gettemplate('forumdisplaybit_threadrate')."\";");
      
$backcolor '#DFDFDF';
          
$bgclass "alt2";
    } else {
                        unset(
$threadrating);
      
$backcolor '#F1F1F1';
          
$bgclass "alt1";
    }

     if (
$announcement[customtitle]==2) {
       
$announcement[usertitle] = htmlspecialchars($announcement[usertitle]);
     }
     
$announcement[postdate]=vbdate($dateformat,$announcement[startdate]);

  if (
$announcement[startdate]>$bbuserinfo[lastvisit]) {
        
$announcement[icon]='newannounce.gif';
  } else {
        
$announcement[icon]='announce.gif';
  }
  eval(
"\$announcement = \"".gettemplate('forumdisplay_announcement')."\";");
  
$doneannouncements 1;

In announcement.php

Look for the following:
PHP Code:
$announcements=$DB_site->query("
SELECT
announcementid,startdate,enddate,announcement.title,pagetext,user.*,userfield.*
"
.iif($avatarenabled,",avatar.avatarpath,NOT ISNULL(customavatar.avatardata) AS hascustomavatar,customavatar.dateline AS avatardateline","")."
FROM announcement
LEFT JOIN user ON user.userid=announcement.userid
LEFT JOIN userfield ON userfield.userid=announcement.userid
"
.iif ($avatarenabled,"LEFT JOIN avatar ON avatar.avatarid=user.avatarid LEFT JOIN customavatar ON customavatar.userid=announcement.userid","")\
.
"
WHERE startdate<='
$datenow' AND enddate>='$datenow' AND $forumlist ORDER BY startdate DESC"); 
And replace it with the following:
PHP Code:
$announcements=$DB_site->query("
SELECT
announcementid,startdate,enddate,announcement.title,pagetext,visits,user.*,userfield.*
"
.iif($avatarenabled,",avatar.avatarpath,NOT ISNULL(customavatar.avatardata) AS hascustomavatar,customavatar.dateline AS avatardateline","")."
FROM announcement
LEFT JOIN user ON user.userid=announcement.userid
LEFT JOIN userfield ON userfield.userid=announcement.userid
"
.iif ($avatarenabled,"LEFT JOIN avatar ON avatar.avatarid=user.avatarid LEFT JOIN customavatar ON customavatar.userid=announcement.userid","")\
.
"
WHERE startdate<='
$datenow' AND enddate>='$datenow' AND $forumlist ORDER BY startdate DESC"); 
In announcement.php

Look for the following:
PHP Code:
  $counter++;
  
//$allowhtml = 1;
  //$announcebits .= getpostbit($post); 
And annd the following directly below it:
PHP Code:
  $DB_site->query("UPDATE announcement set visits=visits+1 where announcementid=$post[announcementid];"); 
That's it.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #22  
Old 08-21-2002, 07:29 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great! I will be looking forward to your solution. Have a great "rest of your vacation" and we'll see you then.

Quote:
Originally posted by Zzed
I'm sorry guys. I am on vacation in Vancouver BC. And my resources are limited. I have this hack working on my 2.2.6. I will have to take a closer look at the problem that was reported by Boofo When I come back this coming weekend. Please accept my apologies.
Reply With Quote
  #23  
Old 08-27-2002, 09:27 PM
Zzed's Avatar
Zzed Zzed is offline
 
Join Date: Feb 2002
Location: Glendale, CA, USA
Posts: 463
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Boofo, all you have to do is replace your current query statement:
PHP Code:
$announcements=$DB_site->query("SELECT announcementid,startdate,title,user.username,user.userid,user.usertitle,user.customtitle
                                         FROM announcement
                                         LEFT JOIN user
                                           ON user.userid=announcement.userid
                                         WHERE startdate<=
$datenow AND enddate>=$datenow
                                           AND 
$forumlist
                                         ORDER BY startdate DESC"
); 
With this:
PHP Code:
$announcements=$DB_site->query("SELECT announcementid,startdate,title,user.username,user.userid,user.usertitle,user.customtitle,visits
                                         FROM announcement
                                         LEFT JOIN user
                                           ON user.userid=announcement.userid
                                         WHERE startdate<=
$datenow AND enddate>=$datenow
                                           AND 
$forumlist
                                         ORDER BY startdate DESC"
); 
I just added the visits to the end of the first line.
Reply With Quote
  #24  
Old 08-27-2002, 10:08 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Zzed. Sorry about the newbie question.
Reply With Quote
  #25  
Old 08-27-2002, 10:10 PM
Zzed's Avatar
Zzed Zzed is offline
 
Join Date: Feb 2002
Location: Glendale, CA, USA
Posts: 463
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You're welcome.
Reply With Quote
  #26  
Old 10-10-2002, 03:15 PM
mike_tcis mike_tcis is offline
 
Join Date: Sep 2002
Location: Tulsa, OK
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Does this hack still work for 2.2.8?
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:59 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.09933 seconds
  • Memory Usage 2,307KB
  • Queries Executed 22 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (8)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (5)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete