vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   How to make a forum list? (https://vborg.vbsupport.ru/showthread.php?t=6155)

12-31-2000 08:16 PM

I asked this a while back, but got no replies. So, I'll ask again...

Can someone please write for me a simple little script that will list (echo or print) a list of all the forums in the message board? Each forum should be listed as a hyperlink to that forum.

For why I need this, please look at my message board: http://www.jjr512.com/bbs/index.php

Notice that at the top of the message board, and on the top of every message board page (forum list, thread list, thread view, etc.) there are hyperlinks into each forum. Many users like to use these, because they can hop around the forums quicker with these than with anything else. I manually created these links, and I'd just like something that will do it automatically, in case my forums change.

12-31-2000 08:24 PM

There is an hack for that already!

But it displays a small bullet list with all forums in order like A, B, C, D.etc?

12-31-2000 08:26 PM

That's fine, I can work out the formatting myself, I just need the actual working part to start with. Can you point me in the right direction?

12-31-2000 08:41 PM

Here it is:

<?php
require("/full/path/to/admin/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$query = "SELECT * FROM forum ORDER BY title ASC";
$resultlatest = mysql_query($query,$db);
while ($latest_array = mysql_fetch_array($resultlatest)) {
echo "<FONT SIZE=\"1\" FACE=\"Verdana, Arial, Helvetica, sans-serif\">&nbsp;°
<A HREF=\"http://www.extremeforums.com/forums/forumdisplay.php?forumid=$latest_array[forumid]\">$latest_array[title]</A></FONT><BR>";
}

?>

12-31-2000 09:00 PM

OK, that works. Now, one last question: Can you modify it so that it sorts the forums in the same order that they appear in the message board?

12-31-2000 09:01 PM

Actually, here's another question: Can we exclude forums that are either really Archives, or else are just closed?

12-31-2000 09:12 PM

Yeah I am sure you can do those things.

12-31-2000 10:22 PM

Umm... I meant could somebody show me how?

12-31-2000 10:36 PM

Here is what I wrote up. It is a little more complicated but is more customizable....

Code:

<?php
require("config.php");
//Changing these flags to Zero will change the output.
$showcat=1;      // Show Categories
$showdesc=1;      // Show Forum Descriptions
$db=mysql_connect($servername,$dbusername,$dbpassword);
mysql_select_db($dbname);
$catquery=("SELECT categoryid,title FROM category WHERE displayorder <> 0 and categoryid<>5 and categoryid<>9 ORDER BY displayorder");
$catresult=mysql_query($catquery,$db);
if ($showcat==1){
  while ($cat = mysql_fetch_array($catresult)) {
    echo ("<font face=\"Arial, Helvetica, sans-serif\" size=\"-1\"><a href=\"http://sitepointforums.com/index.php?categoryid=".$cat[categoryid]."\">".$cat[title]."</a></font><br>");
    $forumquery=("SELECT forumid,title,description FROM forum WHERE showactive=1 and categoryid=$cat[categoryid] ORDER BY displayorder");
    $forumresult=mysql_query($forumquery,$db);
    while ($forum = mysql_fetch_array($forumresult)) {
      if ($showdesc==1) {
        echo ("<font face=\"Arial, Helvetica, sans-serif\" size=\"-3\"><a href=\"http://sitepointforums.com/forumdisplay.php?forum=".$forum[forumid]."\">".$forum[title]."</a><br>".$forum[description]."</font><br>");
      }
      else {
        echo ("<font face=\"Arial, Helvetica, sans-serif\" size=\"-3\"><a href=\"http://sitepointforums.com/forumdisplay.php?forum=".$forum[forumid]."\">".$forum[title]."</a></font><br>");
      }
    }
  }
}
else {
  $forumquery=("SELECT forumid,title,description FROM forum WHERE showactive=1 ORDER BY displayorder");
  $forumresult=mysql_query($forumquery,$db);
  while ($forum = mysql_fetch_array($forumresult)) {
    if ($showdesc==1) {
      echo ("<font face=\"Arial, Helvetica, sans-serif\" size=\"-3\"><a href=\"http://sitepointforums.com/forumdisplay.php?forum=".$forum[forumid]."\">".$forum[title]."</a><br>".$forum[description]."</font><br>");
    }
    else {
      echo ("<font face=\"Arial, Helvetica, sans-serif\" size=\"-3\"><a href=\"http://sitepointforums.com/forumdisplay.php?forum=".$forum[forumid]."\">".$forum[title]."</a></font><br>");
    }
  }
}
?>

This code requires a custom field to be added to your Forum table... It should be:
showactive smallint(6) default 1

setting that column to zero will prevent particular forums from showing. Also if you want to exclude different categories then you can change the line:
Code:

$catquery=("SELECT categoryid,title FROM category WHERE displayorder <> 0 and categoryid<>5 and categoryid<>9 ORDER BY displayorder");
To reflect your restricted categories.

01-01-2001 02:33 AM

Hmm... I thought the solution would involve something similar to this piece of code:
Code:

$querylatest="SELECT * FROM thread WHERE forumid='1' OR forumid='2' OR forumid='3' OR forumid='4' OR forumid='5' OR forumid='6' OR forumid='8' OR forumid='11' OR forumid='12' OR forumid='13' ORDER BY lastpost DESC LIMIT $num_active";
That selects which forums to include (taken from the active topics hack). Now, I don't remember the exact syntax, but I thought there was a way to have a similar statement, only instead of explicitly specifying which forums to select, it could be written to select all forums except private ones. Well, I'd like to include private forums, but I thought that it could be modified so that it selected all forums except those that are off.

(I'm trying to avoid modifying the database, I haven't even backed it up yet and don't know how, and I'm uncomfortable messing with it. Besides, I think there must be a more elegant solution.)


All times are GMT. The time now is 08:08 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.01072 seconds
  • Memory Usage 1,738KB
  • 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
  • (3)bbcode_code_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