Announcement

Collapse
No announcement yet.

[Mini-RELEASE v2] Print linked list of forums in any template

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • rylin
    replied
    real codexample
    PHP Code:
    function getChildren($parentid=-1) {
     
    $res=$DB_site->query("SELECT forumid,title FROM forum WHERE parentid='$parentid' ORDER BY displayorder ASC");
     while(
    $row=$DB_site->fetch_array($res)) {
      echo 
    "<a href='forumdisplay.php?forumid=$row[forumid]'>$row[title]</a> ";
      
    getChildren($row[forumid]);
     }

    should work reasonably fast, but of course, not as fast as pure mysql.. oh well

    Leave a comment:


  • Hooper
    replied
    Thank you okidoki. That was very nice. Much appreciated.

    Leave a comment:


  • rylin
    replied
    regarding the displayorder.. if you want a simple fix,
    begin by selecting everything that's at the root level (parent id -1 or 0 i believe), then you just loop through that with a while statement, doing the queries according to the current parentid.. yes, it will be slower than getting it straight from the mysqld, but it shouldn't differ too much..

    example of recursiveness.. should work, except your going to have to rewrite it into actual code (mainly because i don't have the vB mysql class calls in my head atm :P)

    getChildren(parentid=-1) { // if the root level isn't -1, replace it with whatever it's supposed to be
    global $db (or whatever the db object is called)

    run the query ("select forumid,title from forum where parentid='$parentid'");
    while(row = fetch the array from the mysql result) {
    echo "<a href='forumid'>title</a> ";
    getChildren(forumid);
    }
    }

    if you still need help with it, i'll take a look tomorrow and add a real code example

    Leave a comment:


  • Hooper
    replied
    Hey Kevin.

    I installed this and it works with 2.03. I however uninstalled it for a couple reasons. As mentioned above, will you have a version of links that will allow certain forums not to be seen? And will it have a better formatting scheme? Like maybe...

    Cat Name

    <space>forum1
    <space>forum2

    and so on? or are you going to do anymore with this? It would be real nice to have an heirarchy of the forums to display.


    Thanks

    Leave a comment:


  • fury
    replied
    Cool hack, but I'll wait to use it until it doesn't display private forums

    I know I could probably modify the forumjump to act the same if I had the php knowledge, but some of the members like the forum jump as a drop-down box

    Leave a comment:


  • JJR512
    replied
    This is now a potential problem for me, as well. Tubedogg, do you think you can include permission-checking into this hack, so that people only see the forums they're allowed to see?

    Leave a comment:


  • alhatali
    replied
    I installed this hack successfully. However, I noticed that the list of forums displayed include private forums, not like the ForumJump list. It is true that when one clicks on a forum that's not allowed to see, they will get the Login In window.

    Is there a way of displaying only the forums that one is allowed to see?

    Leave a comment:


  • tubedogg
    replied
    General has a displayorder of 1, and computer stuff has a displayorder of 2, both of which are *not* the forum id (or parent id).

    OK. Ignoring displayorder for a minute:
    Code:
    General > forumid = 19. (any sub-forums will have a parentid of 19)
        MB > forumid = 1, parentid = 19.
    Computer Stuff > forumid = 17. (any sub-forums will have a parentid of 17)
        Hardware & Overclocking > forumid = 3, parentid = 17.
    If I order by parentid, Hardware & Overclocking (parentid=17) comes up first, then MB (parentid=19) because 17 < 19.

    See now?

    Leave a comment:


  • JJR512
    replied
    Umm...I don't see where you're going, because you lost me with "General's id = 19". General has an ID of 1, and Computer Stuff has an ID of 2. Where did 19 and 17 come from?

    Leave a comment:


  • tubedogg
    replied
    Ahh I figured it out

    Because parent id (which is equal to the forum id of the parent in question) is different from display order. On your site, General's id = 19, so for the MB forum, the parent id is 19. However, in Computer Stuff (id = 17), Hardware & Overclocking has a parent id of 17. See where I'm going?

    I'm gonna have to figure out a way to use the parent list. But I have *no* idea how it works, at least not yet. I'm getting there.

    Leave a comment:


  • JJR512
    replied
    I guess what I don't understand, then, is why were the categories shown in the wrong order in my case? "Mindless Blabbering" has a lower number than "Hardware", and the category that "MB" is in has a lower number than the category that "Hardware" is in. So regardless of if it was ordered by category first, then by forum, or just by forum, "MB" should have been first. But all the forums in the "Computer Stuff" category were displayed first, it the correct order within that category.

    Leave a comment:


  • tubedogg
    replied
    Hi JJR

    I've been thinking about this one and looking over the forum table again to see what I can do about it. You're right - the way you have yours set up, it works. However, on a board such as mine, I have the displayorder duplicated for each category. e.g.
    Code:
    General: 1
    ---Announcements: 1
    The Real World: 2
    ---New Season: 1
    ---Old Season: 2
    ---Casting: 3
    Road Rules: 3
    ---New Season: 1
    ---Old Season: 2
    ---Casting: 3
    The Void: 4
    ---Reality Online: 1
    ---Off-topic rambling: 2
    ---Bug Reports: 3
    ---Testing testing: 4
    (I left some off, but you get the idea.) So in that case, it wouldn't work. I'm trying to figure out a way around this - I think I'm gonna have to do some investigation of the parentlist field. I'll let y'all know when I come up with something.

    Leave a comment:


  • JJR512
    replied
    OK, I don't know much about PHP or MySql, but have learned enough by applying hacks to think I can experiment a little, hopefully without making the planet explode or anything. ANYway, I know that the order in which the forums are listed are controlled by this part...
    Code:
    ORDER BY parentid,displayorder
    ...which is part of the code that gets added to functions.php.

    So I tried reversing them to see what would happen, so it looks like this...
    Code:
    ORDER BY displayorder,parentid
    ...and now it works find. The forums are displayed in the correct order.

    Now if anyone would like to see a demo, look here:
    http://www.jjr512.com/forums/index.php?s=
    And look just under the dark blue navigation bar. You'll see a hyperlinked list of all my active forums. To me (and my users), this is better than the forumjump feature. It's easier to use; just click a link. One step, all there is to it. The forumjump feature requires you open the drop-down box, select the forum, etc.; hardly requires a Ph.D., but still it's a few more steps.

    Also, I've added it at the bottom of the page, in this case just above the dark blue navigation band. If you look at my message board, you'll see I've also added the navbar below the tables as well (the navbar is the part that shows the BBS name, the forum name, and if in a thread, the thread name, all as links, so you can go back up a level). I find the navbar (and the forumlinks from this hack) to actually be more useful at the bottom. Think about it. When you read through a thread, and read the last message, where do you end up? At the bottom. So why not put the links there, instead of making you have to scroll back up to the top.

    Edited to add: I put the $forumlinks1 in the header and footer templates, so they appear on every page.

    Leave a comment:


  • JJR512
    replied
    OK, now all the forums are being displayed that I want to be displayed, and the ones that shouldn't be displayed are not displayed. That, in other words, is correct. Only thing is an archive is being displayed, too, which I would prefer not to, but I guess is acceptable. Although is there a way to exclude an archive? I guess that is a forum that is closed or locked.

    Now the problem is the display order.

    Here is how I have my category and forum display orders set:
    Code:
    General: 1
         Mindless Blabbering: 1
         Current Events: 2
         Useless Trivia: 3
         Sports: 4
         Entertainment: 5
         Automobiles: 6
    Computer Stuff: 2
         Hardware: 7
         Software: 8
         Gaming: 9
         SETI: 10
    Site Related: 3
         Feedback: 11
         Moderator's Hideout: 12
    Now for some reason, the Computer Stuff category's forums are displaying first, in order, then the Site Related category's forums are displaying, and finally the General category's forums are displaying (again, in order). So it seems that within each category, the forums are displayed in proper order, it's just that the categories are not displayed in order themselves.

    Leave a comment:


  • tubedogg
    replied
    I updated it to v0.0.2, which fixes the problems that JJR mentioned. As for a demo, you're just gonna have to wait. I can't really implement it on my forum, so...Plus there's not much to see. It basically just creates a list of forums, useful if you don't want to use forumjump.

    Leave a comment:

Related Topics

Collapse

Working...
X