Thread Rating:
  • 2 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Adding Paging to the Portal Page
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #1
Adding Paging to the Portal Page
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:
1
2
3
4
5
6
7
8
$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:
1
2
3
4
5
6
7
8
9
10
11
12
13
$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:
1
2
3
4
5
6
7
8
$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:
1
2
3
4
5
6
7
8
$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.


My Blog
01-27-2008 11:31 AM
Find all posts by this user
incadude Offline
Member
***
Posts: 52
Joined: Jan 2008
Post: #2
RE: Adding Paging to the Portal Page
cool i wonder why mybb didn't come with this?
01-27-2008 11:32 AM
Find all posts by this user
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #3
RE: Adding Paging to the Portal Page
I really don't know either - it's really not that difficult... >_>

My Blog
01-27-2008 11:34 AM
Find all posts by this user
goindex Offline
Junior Member
**
Posts: 23
Joined: Jan 2008
Post: #4
RE: Adding Paging to the Portal Page
Is not difficult and this is really nice !
Thank's again !

My Site | My Posts | My Profil | My Favorites Plugins
01-27-2008 05:04 PM
Find all posts by this user
pepotiger Offline
Junior Member
**
Posts: 18
Joined: Jan 2008
Post: #5
RE: Adding Paging to the Portal Page
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]

(This post was last modified: 01-28-2008 01:56 AM by pepotiger.)
01-28-2008 01:03 AM
Find all posts by this user
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #6
RE: Adding Paging to the Portal Page
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

My Blog
01-28-2008 06:30 PM
Find all posts by this user
pepotiger Offline
Junior Member
**
Posts: 18
Joined: Jan 2008
Post: #7
RE: Adding Paging to the Portal Page
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.
(This post was last modified: 01-28-2008 11:05 PM by pepotiger.)
01-28-2008 09:41 PM
Find all posts by this user
Guest
Unregistered
 
Post: #8
RE: Adding Paging to the Portal Page
makes the portal sidebox very small
02-04-2008 10:36 AM
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #9
RE: Adding Paging to the Portal Page
^ 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.

My Blog
(This post was last modified: 02-04-2008 01:42 PM by ZiNgA BuRgA.)
02-04-2008 01:42 PM
Find all posts by this user
snAke Offline
Banana-Presi
**
Posts: 19
Joined: Feb 2008
Post: #10
RE: Adding Paging to the Portal Page
i did'nt change anything in my tempelate only {$multipage}
take a look: link
User: Max Mustermann
Pass: Max Mustermann

if ( $Idea == 'none' ) { read (FAQ) && search (search) }
else if ($answer == 0) { post->question }
02-05-2008 10:38 AM
Visit this user's website Find all posts by this user

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: