MyBB Community Forums

Full Version: topic titles on portal from specific fid
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello!

I'm a butcher when it comes to adding/modifying snippets of MyBB code to customize certain things, just so you know Big Grin

I'm looking for a simple code that I can insert at a specific location on the portal page which shows x-number of topic titles of a specific forum, ordered by oldest first, newest last and not older than date y.

I tried to butcher some old code I once got from around here (which was meant for something else but had a lot of similarities) but I can't seem to be able to build something like this. I assume it's pretty easy to do, hopefully somebody can help me with this Smile
This was the code I used for displaying certain topics on my frontpage website (www.example.com which was pulling the forum data from www.example.com/forum).

Code between the </head> and <body> tag of the page.
<?php

    $fid = 2;
    $limit = 12;
    $forumpath = 'forum/';

    chdir($forumpath);
    define("IN_MYBB", 1);
    require('./global.php');
    require_once MYBB_ROOT."inc/class_parser.php";
    $parser = new postParser;
    chdir('../');
?>

Code on the www.example.com/index.php page.
  <?php
    
    $query = $db->simple_select('threads', '*', "fid='2' OR fid='122' ORDER BY tid DESC LIMIT {$limit}");
    if($db->num_rows($query) > 0)
    {
        while($row = $db->fetch_array($query))
        {
            $query2 = $db->simple_select('posts', '*', "pid='{$row['firstpost']}'");
            $row2 = $db->fetch_array($query2);
            
            $date = my_date($mybb->settings['dateformat'], $row2['dateline'], "", 1);
            $time = my_date($mybb->settings['timeformat'], $row2['dateline'], "", 1);

            $options = array(
                            'allow_html' => '1', 
                            'filter_badwords' => '1', 
                            'allow_mycode' => '1', 
                            'allow_smilies' => '1', 
                            'nl2br' => '1', 
                            'me_username' => '1'
                            );
            $message = $parser->parse_message($row2['message'], $options);
	   	echo("<a href=\"/showthread.php?tid={$row['tid']}\">{$row['subject']}</a>");
	    }
    }
    else
    {
        echo 'Nothing to display.';
    }
?>

I tried to modify above codes to get it working on www.example.com/forum/portal.php but no matter what I try, the portal.php will become blank as soon as I add this code or modified versions of the code.