MyBB Community Forums

Full Version: Extracting the latest posts from portal.php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I can find the PHP script that gets the latest threads, but I cant seem to find the variable in which they are stored, would anyone be able to point mein the right direction?
Sorry - I am not quite sure what you are talking about - but:

to set the forum in which the information threads are pulled from, go to the Admin CP -> Settings -> Portal

The information is there. You can also set 8 other options for this.

Hope I helped
What I mean is you know the list of latest threads down te side of the portal, I want to extract that to a seperate page, but how?
The variable that stores the whole "Latest Threads" table is $latestthreads.

eval("\$latestthreads = \"".$templates->get("portal_latestthreads")."\";");
So I'd have the bit that is commented as "Get latest posts" and then do echo($latestthreads)?
Can someone tell me what is wrong with this script Confused I have tried for about 20 min ro get it to work.. but with no luck..

<?
$db = mysql_connect('Edited...', 'edited.. I wonder why?', 'edited to...');
$altbg = "trow1";
	$query = mysql_query("SELECT t.*, u.username FROM threads t LEFT JOIN users u ON (u.uid=t.uid) WHERE 1=1 AND t.visible='1' AND t.closed NOT LIKE 'moved|%' ORDER BY t.lastpost DESC  LIMIT 0, 10", $db);
	while($thread = $query)
	{
		if($thread['lastpost'] != "" && $thread['lastposter'] != "")
		{
			$lastpostdate = mydate("1 dS of F Y", $thread['lastpost']);
			$lastposttime = mydate("h:i:s A", $thread['lastpost']);
			eval("\$lastpost = \"".$templates->get("portal_latestthreads_thread_lastpost")."\";");
		}
		else
		{
			$lastpost = "";
		}
		$thread['subject'] = stripslashes($thread['subject']);
		if(strlen($thread['subject']) > 25)
		{
			$thread['subject'] = substr($thread['subject'], 0, 25) . "...";
		}
		$thread['subject'] = htmlspecialchars($thread['subject']);
		eval("\$threadlist .= \"".$templates->get("portal_latestthreads_thread")."\";");
		if($altbg == "trow1")
		{
			$altbg = "trow2";
		}
		else
		{
			$altbg = "trow1";
		}
	}
	
	eval("\$latestthreads = \""."<table><td>$latestthreads<tr></tr></td>"."\";");
	print($latestthreads);



?>

It just shows a blank page...
It doesn't appear you connected to a database. I see where you connect to the mysql server but I don't see a call to mysql_select_db(). On top of that you are calling a method of a class that doesn't exist (attempting to call get() of the templates class).

Odd.. maybe any of you know.. I've changed it so that it selects the db at the start, and ive replaced get template with the HTML from the template, but I cant get any further becasue of a parse error :@!

Can anyone help me, this is the line in question...

$query = mysql_query("SELECT t.*, u.username FROM threads t LEFT JOIN users u ON (u.uid=t.uid) WHERE 1=1 AND t.visible='1' AND t.closed NOT LIKE 'moved|%' ORDER BY t.lastpost DESC LIMIT 0, 10");
Well. I fixed that problem.. now I have a bigger one!

Itcomes up with hundreds of warning messages warning me that I cannot use a scalar variable as an array on line 19:

$thread['subject'] = stripslashes($thread['subject']);

and 24:
$thread['subject'] = htmlspecialchars($thread['subject']);

Any ideas?
Yesss!!!!!!

I got it to work!

It neds to be formatted.. but its generally right!

www.gamesnetuk.co.uk look at the right!
Pages: 1 2