MyBB Hacks

Full Version: Adding Paging to the Portal Page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
This is something I also find useful if you want your portal page to be more of a blog.
This allows users to browse past announcements - ie further than the cutoff.


To do this, open up portal.php
Find:

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

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

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

PHP Code:
$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.

cool i wonder why mybb didn't come with this?
I really don't know either - it's really not that difficult... >_>
Is not difficult and this is really nice !
Thank's again !
thanks mate, I was looking for it Smile
I was wonder, is there is anyway to change <a href="/portal.php?paged=1&page=([1-9])
to <a href="/portal-page-([1-9]).html ??
to recall it via mod_rewrite with something like that

Code:
RewriteRule ^portal-page-([0-9]+).html(.*)$ portal.php?paged=1&page=$1 [QSA,L]

It would be a bit more of an edit, as MyBB's multipage() function uses the &amp;page=(0-9)+ type format.

If you're familiar with PHP, you can copy the multipage() function and edit it to your liking Smile
thanks mate for clear it for me. I'll take a look at it, if I get any trouble, I'll ask you for help..
Edit: I just want to thank you once more mate. my portal looks great now, I wont done it like that without your help.

Guest

makes the portal sidebox very small
^ That's an issue with your template - not an issue with this modification.

In fact, this won't change the look of anything - you have to edit the template.
i did'nt change anything in my tempelate only {$multipage}
take a look: link
User: Max Mustermann
Pass: Max Mustermann
Pages: 1 2
Reference URL's