1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Show latest threads from XenForo in PHP

Discussion in 'Tips and Guides [Archive]' started by Puntocom, Nov 29, 2010.

  1. Puntocom

    Puntocom Well-Known Member

    I have written this code, I post here hoping it to be useful for you:

    $db_username "USERNAME";
    $db_password "PASSWORD";

    $link mysql_connect($hostname$db_username$db_password) or die("Cannot connect to the database");
    mysql_select_db("DATABASE") or die("Cannot select the database");

    $q "SELECT thread_id,title,username,first_post_id FROM xf_thread WHERE first_post_id > 0 ORDER BY thread_id DESC LIMIT 0,10";
    $r mysql_query($q);
    while (
    $row mysql_fetch_array($r)) {
    $title utf8_encode($row["title"]);
    $first_post_id $row["first_post_id"];
    $limit 26;
            if (
    strlen($title) > $limit)
    $title substr($title0strrpos(substr($title0$limit), ' ')) . '...';
    $tid $row["tid"];
    "<li><a target=\"blank\" href=\"http://www.YOURDOMAIN/posts/$first_post_id\">$title</a></li>";
  2. Pete

    Pete Member

    You might want to add an additional where on the 'discussion_state' column. At the moment you're displaying all threads, regardless of their state. State can be one of visible, moderated or deleted.
    Also, 'discussion_open' for open/close status.
    There may also be other thread states which you may not want to show. At the moment your code displays them all.
    Puntocom likes this.
  3. Puntocom

    Puntocom Well-Known Member

    Thank you I'll look into that to modify the code.
  4. ragtek

    ragtek Guest

    With this script you also show the "hidden" threads from forums which are not public;) (for example adminboard, modboard, etc...)
    Puntocom likes this.

Share This Page