MyBB Community Forums

Full Version: Possible to do this in portal?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I hope this is the right section for this :|

Anyways, I really like the MyBB portal, and I want to use it in place of a blog. But I was wondering if:
1) I could add "Previous" and "Next" links which pull out older/newer announcements - like in blogs
2) Under the topic title, there's something like Posted by USER - DATE - REPLIES - would it be possible to add a SECTION (the name of the forum the thread came from) field?

Many thanks for any replies Smile
:/

Seems like no-one answered me :|

I'm really new to PHP and SQL, so I tried to do this myself:

In portal.php:
Find:
$pids = '';
$comma="";
$query = $db->query("
	SELECT p.pid, p.message, p.tid
	FROM ".TABLE_PREFIX."posts p
	LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
	WHERE t.fid IN (".$mybb->settings['portal_announcementsfid'].") AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND t.firstpost=p.pid
	ORDER BY t.dateline DESC 
	LIMIT 0, ".$mybb->settings['portal_numannouncements']
);
Replace with:
$pids = '';
$comma="";
$apage = intval($_GET['p']);
if($apage < 1)$apage = 1;
$asect = intval($_GET['s']);
if($asect > 0)
{
	$asectq = " AND t.fid='".$asect."'";
	$asectu = "s=".$asect."&";
}
else
{
	$asectq = "";
	$asectu = "";
}

$query = $db->query("
	SELECT p.pid, p.message, p.tid
	FROM ".TABLE_PREFIX."posts p
	LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
	WHERE t.fid IN (".$mybb->settings['portal_announcementsfid'].") AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND t.firstpost=p.pid".$asectq."
	ORDER BY t.dateline DESC 
	LIMIT ".($mybb->settings['portal_numannouncements'] * ($apage - 1)).", ".$mybb->settings['portal_numannouncements']
);

Find:
$query = $db->query("
	SELECT t.*, t.username AS threadusername, u.username, u.avatar
	FROM ".TABLE_PREFIX."threads t
	LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = t.uid)
	WHERE fid IN (".$mybb->settings['portal_announcementsfid'].") AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
	ORDER BY t.dateline DESC
	LIMIT 0, ".$mybb->settings['portal_numannouncements']
);
Replace with:
$query = $db->query("
	SELECT t.*, t.username AS threadusername, t.fid AS forumid, u.username, u.avatar, f.name AS forumname
	FROM ".TABLE_PREFIX."threads t
	LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = t.uid)
	LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid = t.fid)
	WHERE t.fid IN (".$mybb->settings['portal_announcementsfid'].") AND t.visible='1' AND t.closed NOT LIKE 'moved|%'".$asectq."
	ORDER BY t.dateline DESC
	LIMIT ".($mybb->settings['portal_numannouncements'] * ($apage - 1)).", ".$mybb->settings['portal_numannouncements']
);

Find:
	$anndate = my_date($mybb->settings['dateformat'], $announcement['dateline']);
	$anntime = my_date($mybb->settings['timeformat'], $announcement['dateline']);
After add:
	$pagenavnext = "<strong><a href=\"{$mybb->settings['bburl']}/portal.php?".$asectu."p=".($apage+1)."\">Older Posts &raquo;</a></strong>";
	if($apage > 1)
		$pagenavprev = "<strong><a href=\"{$mybb->settings['bburl']}/portal.php?".$asectu."p=".($apage-1)."\">&laquo; Newer Posts</a></strong>";
	else
		$pagenavprev = "";
	
	if($pagenavnext != "" || $pagenavprev != "")
		$pagenav = "<table cellpadding=\"4\" cellspacing=\"0\" class=\"tborder\"><tr class=\"tfoot\"><td>".$pagenavprev."</td><td align=\"right\">".$pagenavnext."</td></tr></table>";
	else
		$pagenav = "";

I don't know how to check if there are any older announcements Confused
Can anyone help me on that?

Since my code probably sucks, feel free to comment on how I can improve it Toungue

Many thanks for any responses.