vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Barebones code to use Javascript to display active topics. (https://vborg.vbsupport.ru/showthread.php?t=19387)

shri 06-05-2001 04:08 PM

Ok.. 5 minute hack based on a request by Craig.

put this in a file called activejs.php in your forum directory.

PHP Code:

<?
        include('./global.php');

        $num_topics = 5;

        $topics_result = $DB_site->query("select * from thread order by lastpost desc limit $num_topics");


        while($topics = $DB_site->fetch_array($topics_result)) {
        $mytitle = addslashes($topics[title]);
        echo ("document.write('<a href=$bburl/showthread.php?threadid=$topics[threadid]>$mytitle</a><br>');\n");
        }

?>

On the page where you want to display the topics put the following.

Code:

<html>
<head>
</head>
<body>
<script LANGUAGE="JavaScript" src="http://www.hkindians.com/forum/activejs.php">
</script>
</body>
</html>


Craig Antill 06-05-2001 07:44 PM

Nice one!! It'll be put to good use - thanks! :D

Steve Machol 06-05-2001 08:35 PM

Nice and easy! The only reason I wouldn't use this is because it includes messages in my private forums. Can this be modifed to ignore privtae forums?

shri 06-06-2001 12:09 AM

Play with the select statement.

Steve Machol 06-06-2001 04:00 AM

[QUOTE]Originally posted by shri
Play with the select statement.

shri 06-06-2001 04:45 AM

Quote:

SELECT * FROM thread WHERE thread.visible=1 and (forumid<>'20' and forumid <> '24' and forumid <> 25 and forumid <> '27' and forumid <> '13' and forumid<> '28') ORDER BY lastpost desc LIMIT 10
You can adapt it. This is simpler but not automated. The automated procedure would be to look at the permissions and see what forums were not viewable by guests and then display the "open forums".

Additionally if you have lots of threads (I have over 30K on one of my forums) you can limit the number of rows scanned by doing something like this in your php code. (You need to add an index on the field 'lastpost' for the table thread).

[php]
$twentyfourhours= 24*60*60;
$date1 = time() - $twentyfourhours * 1;
[php]

Make your select statement ...

Quote:

SELECT * FROM thread WHERE thread.visible=1 and (forumid<>'20' and forumid <> '24' and forumid <> 25 and forumid <> '27' and forumid <> '13' and forumid<> '28') and (lastpost > date1) ORDER BY lastpost desc LIMIT 10

Craig Antill 06-08-2001 04:35 PM

Any idea how to add the date of the post ? One of my partner sites is asking for this to harmonise with the rest of their data on their site :)


All times are GMT. The time now is 02:41 AM.

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.01543 seconds
  • Memory Usage 1,726KB
  • 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
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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