MyBB Community Forums

Full Version: Pagination in portal page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Ok I was browsing ZiNgA BuRgA's old forums, and I found this: http://mybbhacks.zingaburga.com/showthread.php?tid=54
And so, I want to know if this also applies for MyBB 1.4.6. Does it?

Regards.
Should be fine for MyBB 1.4.6;
Hey,

The post is under the forum MyBB 1.2 so it's only for version MyBB 1.2

I have tested this on MyBB 1.4.8 and it doesn't work.

Can someone modify this so it works with MyBB 1.4.8. This modification includes pagination to portal.php so users can read through the older news.

Here is the code *THAT NEEDS TO BE UPDATED/FIXED/MODIFIED* for it be compatible with MyBB 1.4.8:

To do this, open up portal.php
Find:


$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:


$page = intval($mybb->input['page']);
if($page < 1) $page = 1;
$numann = $db->fetch_field($db->simple_select(TABLE_PREFIX.'threads', 'COUNT(*) AS numann', "fid IN (".$mybb->settings['portal_announcementsfid'].") AND visible='1' AND closed NOT LIKE 'moved|%'"), 'numann');
$perpage = intval($mybb->settings['portal_numannouncements']);
$multipage = multipage($numann, $perpage, $page, $_SERVER['PHP_SELF'].'?paged=1');
$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 ".(($page-1)*$perpage).", ".$perpage
);

Then 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, 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 ".(($page-1)*$perpage).", ".$perpage
);

Once you've done the above modifications, just open up your portal template, and add {$multipage} wherever you want your pagination to be.

That's the code for version MyBB 1.2
Can you put the codes in PHP code tags?
[php]code[/php]
bump?
Bump please
I will take a look at this is a bit, the difference between teh 1.4 portal and 1.2. I will try it for the weekend.
bump?
I'm off to bed now (school Sad) but I'll take a look tomorrow. I'm also interested in this. Might try for a plugin of some sorts. Toungue
From memory, just don't do the second replacement.
Pages: 1 2