PDA

View Full Version : Barebones code to use Javascript to display active topics.


shri
05 Jun 2001, 17:08
Ok.. 5 minute hack based on a request by Craig.

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



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



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



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

Craig Antill
05 Jun 2001, 20:44
Nice one!! It'll be put to good use - thanks! :D

Steve Machol
05 Jun 2001, 21:35
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 Jun 2001, 01:09
Play with the select statement.

Steve Machol
06 Jun 2001, 05:00
Originally posted by shri
Play with the select statement.

I would but my wife frowns on that sort of thing! :D

Seriously though, I have no idea what to do with the select statement. MySQL is very new to me.

shri
06 Jun 2001, 05:45
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 ...


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
08 Jun 2001, 17:35
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 :)