vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Most viewed thread by forum ? (https://vborg.vbsupport.ru/showthread.php?t=6712)

01-12-2001 11:33 AM

Anyone done this yet ?

a simple page listing most viewed thread in the past X days , sorted by forum which the thread hyperlinked showing the number of replies and views

- mostviewedthread [views: xx] [replies: xx]

01-12-2001 12:26 PM

Shows within the last 30 days.
Code:

<?
require("global.php");

$foruminfo=$DB_site->query("SELECT forumid, title FROM forum ORDER BY categoryid,displayorder");
while ($forum=$DB_site->fetch_array($foruminfo)) {
  echo ("<a href=\"forumdisplay.php?forumid=".$forum[forumid]."\">".$forum[title]."</a><br>");
  $threadinfo=$DB_site->query_first("SELECT threadid,title,replycount,views FROM thread WHERE forumid=$forum[forumid] and dateline > UNIX_TIMESTAMP(curdate()-30) ORDER BY views DESC LIMIT 1");
  echo ("&nbsp;&nbsp;<a href=\"showthread.php?threadid=".$threadinfo[threadid]."\">".htmlspecialchars($threadinfo[title])."</a>&nbsp;[views: ".$threadinfo[views]."]&nbsp;[replies: ".$threadinfo[replycount]."]<br>");
}

?>


Demo: http://sitepointforums.com/mostviewed.php

If you want to exclude certain forums. i.e. moderator forums, then add a WHERE clause to $foruminfo... For example:
WHERE forumid<>1

01-12-2001 12:33 PM

thanks.. is can be modified to slow the top X or 5 viewed threads per forum ?

forum 1
1. - mostviewedthread - [views: xx] [replies: xx]
2. - 2ndmostviewedthread - [views: xx] [replies: xx]
3. - 3rdmostviewedthread - [views: xx] [replies: xx]
4. - 4thmostviewedthread - [views: xx] [replies: xx]
5. - 5thmostviewedthread - [views: xx] [replies: xx]

forum 2
1. - mostviewedthread - [views: xx] [replies: xx]
2. - 2ndmostviewedthread - [views: xx] [replies: xx]
3. - 3rdmostviewedthread - [views: xx] [replies: xx]
4. - 4thmostviewedthread - [views: xx] [replies: xx]
5. - 5thmostviewedthread - [views: xx] [replies: xx]

all most forgot where forum is listed in order of diplay on forumhome page :)

thanks

[Edited by eva2000 on 01-12-2001 at 09:41 AM]

01-12-2001 02:45 PM

The forums should already be listed in the order they are displayed in forumhome. It orders them by categoryid and then by displayorder to get the same sequence.

Here is the code where you can change the number of threads shown. Just change the LIMIT on the second Query to modify the amount.

Code:

<?
require("global.php");

$foruminfo=$DB_site->query("SELECT forumid, title FROM forum ORDER BY categoryid,displayorder");
while ($forum=$DB_site->fetch_array($foruminfo)) {
  echo ("<a href=\"forumdisplay.php?forumid=".$forum[forumid]."\">".$forum[title]."</a><br>");
  $threadinfo=$DB_site->query("SELECT threadid,title,replycount,views FROM thread WHERE forumid=$forum[forumid] AND dateline > UNIX_TIMESTAMP(curdate()-30) ORDER BY views DESC LIMIT 5");
  while ($thread=$DB_site->fetch_array($threadinfo)) {
    echo ("&nbsp;&nbsp;<a href=\"showthread.php?threadid=".$thread[threadid]."\">".htmlspecialchars($thread[title])."</a>&nbsp;[views: ".$thread[views]."]&nbsp;[replies: ".$thread[replycount]."]<br>");
  }
}

?>


01-12-2001 05:56 PM

thanks.. it works perfectly :)

http://animeboards.net/forums/mostviewed.php
although for some reason the last recent forums i added, are old of the sort and display order i have on my forums ?

01-12-2001 06:14 PM

There seems to be a problem with your global.php file...

Warning: Cannot add header information - headers already sent by (output started at /home/animeboa/public_html/forums/mostviewed.php:7) in /home/animeboa/public_html/forums/global.php on line 756

Warning: Cannot add header information - headers already sent by (output started at /home/animeboa/public_html/forums/mostviewed.php:7) in /home/animeboa/public_html/forums/global.php on line 763

01-13-2001 03:56 AM

btw, this is OT, but i figure its not a *bad* spot to suggest it. my board has a few threads that have over 2^16-1 views, and the counter stops there.

might wanna fix that for v2.0 :)

01-13-2001 04:59 AM

Quote:

Originally posted by wluke
There seems to be a problem with your global.php file...

Warning: Cannot add header information - headers already sent by (output started at /home/animeboa/public_html/forums/mostviewed.php:7) in /home/animeboa/public_html/forums/global.php on line 756

Warning: Cannot add header information - headers already sent by (output started at /home/animeboa/public_html/forums/mostviewed.php:7) in /home/animeboa/public_html/forums/global.php on line 763


thanks.. i had some server problems and was playing around with the formatting.. it should work now :)

01-13-2001 12:49 PM

Nice addon but any way i can stop it displying private section posts?
thanks
cya trin

01-13-2001 04:18 PM

Quote:

Originally posted by wluke
If you want to exclude certain forums. i.e. moderator forums, then add a WHERE clause to $foruminfo... For example:
WHERE forumid<>1




All times are GMT. The time now is 06:52 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.01106 seconds
  • Memory Usage 1,737KB
  • 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
  • (2)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete