Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases
FAQ Community Calendar Today's Posts Search

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
  #12  
Old 04-17-2002, 06:44 PM
mnsour mnsour is offline
 
Join Date: Nov 2001
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks

it's nice
Reply With Quote
  #13  
Old 04-18-2002, 06:07 PM
inetd inetd is offline
 
Join Date: Nov 2001
Posts: 332
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Zzed! Thanks! I install this hack!
Reply With Quote
  #14  
Old 04-18-2002, 06:21 PM
Chris M's Avatar
Chris M Chris M is offline
 
Join Date: Dec 2001
Location: Northampton, England
Posts: 6,186
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nice hack...

I might install it later if I have the time...

Satan
Reply With Quote
  #15  
Old 08-21-2002, 04:11 AM
Sho Sho is offline
 
Join Date: Nov 2001
Location: Berlin, Germany
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Unfortunately, the code we have to search for has changed in 2.2.6, and I am reluctant to experiment with it. Zzed, could you provide us with updated instructions?
Reply With Quote
  #16  
Old 08-21-2002, 04:39 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Zzed,

Here is the code I have for the forimdisplay.php part. How do I do the code to replace it?

PHP Code:
// get announcements
$datenow=time();
$forumlist=getforumlist($forumid,'forumid');
$doneannouncements 0;
$announcementbit="";
$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"
);
while(
$announcement=$DB_site->fetch_array($announcements)) {
    if (
$foruminfo[allowratings]) {
      
$thread[rating]='clear.gif';
      eval(
"\$threadrating = \"".gettemplate('forumdisplaybit_threadrate')."\";");
      
$backcolor '{secondaltcolor}';
          
$bgclass "alt2";
    } else {
            unset(
$threadrating);
      
$backcolor '{firstaltcolor}';
          
$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(
"\$announcementbit .= \"".gettemplate('forumdisplay_announcement')."\";");
  
$doneannouncements 1;
}
$announcement=$announcementbit
Reply With Quote
  #17  
Old 08-21-2002, 04:45 AM
Sho Sho is offline
 
Join Date: Nov 2001
Location: Berlin, Germany
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just got it working for 2.2.6.

forumdisplay.php:

Search for:

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 '{secondaltcolor}';
          
$bgclass "alt2";
    } else {
            unset(
$threadrating);
      
$backcolor '{firstaltcolor}';
          
$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;

Replace with:

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 '{secondaltcolor}';
          
$bgclass "alt2";
    } else {
            unset(
$threadrating);
      
$backcolor '{firstaltcolor}';
          
$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;

announcement.php:

Search for:

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");
while (
$post=$DB_site->fetch_array($announcements)) { 
Replace with:

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");
while (
$post=$DB_site->fetch_array($announcements)) { 
Everything else works still like Zzed told us.

Btw, 'morning Boofo. Slept only 3 1/2 hours.
Reply With Quote
  #18  
Old 08-21-2002, 05:02 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That won't work for me, Sho. I don't have the if ($announcement thing at all.
Reply With Quote
  #19  
Old 08-21-2002, 05:07 AM
Sho Sho is offline
 
Join Date: Nov 2001
Location: Berlin, Germany
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, it's for 2.2.6 - you use 2.2.5, if I remember correctly?
Reply With Quote
  #20  
Old 08-21-2002, 05:10 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's right.
Reply With Quote
  #21  
Old 08-21-2002, 07:27 AM
Zzed's Avatar
Zzed Zzed is offline
 
Join Date: Feb 2002
Location: Glendale, CA, USA
Posts: 463
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply


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 04:32 PM.


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.05035 seconds
  • Memory Usage 2,412KB
  • Queries Executed 25 (?)
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
  • (11)bbcode_php
  • (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
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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_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