boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Hacks] Vbulletin Style Page Numbers
Goto page 1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    boardom Forum Index -> Hacks
View previous topic :: View next topic  
Author Message
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Sun Jan 05, 2003 4:37 pm    Post subject: [Hacks] Vbulletin Style Page Numbers Reply with quote

I have created a function to have vbulletin style page numbering like Pages (9): [1] 2 3 4 5 » ... Last »

Open up b2template.functions.php add in this function[php:1:40d3d09621]function pagenavi($prelabel='<< Previous Page', $nxtlabel='Next Page >>') {
global $p, $what_to_show, $request, $posts_per_page;
global $HTTP_SERVER_VARS, $siteurl, $blogfilename, $paged;
global $querystring_start, $querystring_equal, $querystring_separator;
if (empty($p) && ($what_to_show == 'paged')) {
$nxt_request = $request;
$whichpage = $_GET['paged'];
if(empty($whichpage)) $whichpage = 1;
$qstr = $HTTP_SERVER_VARS['QUERY_STRING'];
if (!empty($qstr)) {
$qstr = preg_replace("/&paged=\d{0,}/","",$qstr);
$qstr = preg_replace("/paged=\d{0,}/","",$qstr);
} elseif (stristr($HTTP_SERVER_VARS['REQUEST_URI'], $HTTP_SERVER_VARS['SCRIPT_NAME'] )) {
if ('' != $qstr = str_replace($HTTP_SERVER_VARS['SCRIPT_NAME'], '', $HTTP_SERVER_VARS['REQUEST_URI']) ) {
$qstr = preg_replace("/^\//", "", $qstr);
$qstr = preg_replace("/paged\/\d{0,}\//", "", $qstr);
$qstr = preg_replace("/paged\/\d{0,}/", "", $qstr);
$qstr = preg_replace("/\/$/", "", $qstr);
}
}
if ($pos = strpos(strtoupper($request), 'LIMIT')) {
$nxt_request = substr($request, 0, $pos);
}
$nxt_result = mysql_query($nxt_request);
$numposts = mysql_num_rows($nxt_result);
$max_page = ceil($numposts / $posts_per_page) ;

echo "Pages(".$max_page.") : <b>";
if ($whichpage >= 4)
echo '<a href="'.$siteurl.'/'.$blogfilename.$querystring_start.($qstr == '' ? '' : $qstr.$querystring_separator) .'paged'.$querystring_equal.'1">« First</a> ... ';
previous_posts_link($prelabel);
for($i = $whichpage - 2 ; $i <= $whichpage +2; $i++) {
if ($i >= 1 && $i <= $max_page) {
if($i == $whichpage)
echo '['.$i.'] ';
else
echo '<a href="'.$siteurl.'/'.$blogfilename.$querystring_start.($qstr == '' ? '' : $qstr.$querystring_separator) .'paged'.$querystring_equal.$i.'">'.$i.'</a> ';
}
}
next_posts_link($nxtlabel, $max_page);
if (($whichpage+2) < ($max_page))
echo ' ... <a href="'.$siteurl.'/'.$blogfilename.$querystring_start.($qstr == '' ? '' : $qstr.$querystring_separator) .'paged'.$querystring_equal.$max_page.'">Last »</a>';
echo "</b>";
}
}[/php:1:40d3d09621]
To call ths function simply use[php:1:40d3d09621]<?php pagenavi("<", ">"); ?>[/php:1:40d3d09621] It is still in developement process. Any bugs pls post here. Thanks.
_________________

++ GamerZ.Per.Sg - Complex Simplicity
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
nessahead



Joined: 12 Mar 2002
Posts: 312
Location: Los Angeles, CA

PostPosted: Mon Jan 06, 2003 1:24 am    Post subject: Reply with quote

Splendid hack Smile I modified it a bit for aesthetics but it works wonderfully Smile
_________________
raar!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Mon Jan 06, 2003 3:05 pm    Post subject: Reply with quote

nessahead wrote:
Splendid hack Smile I modified it a bit for aesthetics but it works wonderfully Smile
hehe thanks, I think there is still bug in it. LOL
_________________

++ GamerZ.Per.Sg - Complex Simplicity
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
ahotasu



Joined: 02 Dec 2002
Posts: 13
Location: Piedmont College

PostPosted: Sat Jan 25, 2003 3:47 pm    Post subject: hi Reply with quote

I'm getting a parse error...

It's reports the last line shown here:
Code:

 function pagenavi($prelabel='<< Previous Page', $nxtlabel='Next Page >>') {
    global $p, $what_to_show, $request, $posts_per_page;
    global $HTTP_SERVER_VARS, $siteurl, $blogfilename, $paged;
    global $querystring_start, $querystring_equal, $querystring_separator;
    if (empty($p) && ($what_to_show == 'paged')) {

Back to top
View user's profile Send private message Visit poster's website AIM Address
macshack



Joined: 17 Jul 2002
Posts: 1204
Location: Phoenix, Az

PostPosted: Sat Jan 25, 2003 8:24 pm    Post subject: Reply with quote

Hi,

I think you will find that && should be &&
Things should then work better.

Michael e
Back to top
View user's profile Send private message Send e-mail
ahotasu



Joined: 02 Dec 2002
Posts: 13
Location: Piedmont College

PostPosted: Sat Jan 25, 2003 9:20 pm    Post subject: Reply with quote

thanks macshack
ok, there were two cases of && that needed to be fixed
line 5 and line 33
i dont get the error anymore but now nothing shows up.

i've tried putting
<?php pagenavi("<", ">"); ?>
both inside and outside the b2 loop but i get nothing.
Back to top
View user's profile Send private message Visit poster's website AIM Address
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Sun Jan 26, 2003 6:01 am    Post subject: Reply with quote

ahotasu wrote:
thanks macshack
ok, there were two cases of && that needed to be fixed
line 5 and line 33
i dont get the error anymore but now nothing shows up.

i've tried putting
<?php pagenavi("<", ">"); ?>
both inside and outside the b2 loop but i get nothing.
what version of b2 u using?
_________________

++ GamerZ.Per.Sg - Complex Simplicity
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
kichu



Joined: 23 Feb 2002
Posts: 53
Location: Chennai,India

PostPosted: Sun Jan 26, 2003 7:30 am    Post subject: Reply with quote

ahotasu wrote:
i've tried putting
<?php pagenavi("<", ">"); ?>
both inside and outside the b2 loop but i get nothing.

Yes, nothing happens to me too!
http://www.cyberbrahma.com/rants/
And I use the latest b2.
Please help.
Thanks
S.K
_________________
Cause something to change, you are not here for ever!
Back to top
View user's profile Send private message Visit poster's website
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Sun Jan 26, 2003 12:14 pm    Post subject: Reply with quote

kichu wrote:
ahotasu wrote:
i've tried putting
<?php pagenavi("<", ">"); ?>
both inside and outside the b2 loop but i get nothing.

Yes, nothing happens to me too!
http://www.cyberbrahma.com/rants/
And I use the latest b2.
Please help.
Thanks
S.K
? I saw it on your page
Pages(2) : [1] 2 >
_________________

++ GamerZ.Per.Sg - Complex Simplicity
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
kichu



Joined: 23 Feb 2002
Posts: 53
Location: Chennai,India

PostPosted: Sun Jan 26, 2003 12:22 pm    Post subject: Reply with quote

Oh! My!
Thanks, Gamerz from Singapore (My Asian neighbour!)
I underestimated the effect of cache!
I shd have known better!
Thanks again.
Regards
S.K
_________________
Cause something to change, you are not here for ever!
Back to top
View user's profile Send private message Visit poster's website
ahotasu



Joined: 02 Dec 2002
Posts: 13
Location: Piedmont College

PostPosted: Sun Jan 26, 2003 9:38 pm    Post subject: Reply with quote

i'm using b2 0.6.1 + ljupdate-0.2

i'm also using the last_visit hack and last 5 comments, but I don't see how those could interfere with this hack...
Back to top
View user's profile Send private message Visit poster's website AIM Address
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Mon Jan 27, 2003 1:59 am    Post subject: Reply with quote

kichu wrote:
Oh! My!
Thanks, Gamerz from Singapore (My Asian neighbour!)
I underestimated the effect of cache!
I shd have known better!
Thanks again.
Regards
S.K
LOL, u from India?
_________________

++ GamerZ.Per.Sg - Complex Simplicity
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Mon Jan 27, 2003 1:59 am    Post subject: Reply with quote

ahotasu wrote:
i'm using b2 0.6.1 + ljupdate-0.2

i'm also using the last_visit hack and last 5 comments, but I don't see how those could interfere with this hack...
? I dun think it will interfere, i am using the last visit hack too.
_________________

++ GamerZ.Per.Sg - Complex Simplicity
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
kichu



Joined: 23 Feb 2002
Posts: 53
Location: Chennai,India

PostPosted: Mon Jan 27, 2003 2:41 am    Post subject: Reply with quote

GamerZ wrote:
u from India?

Yes!
In a city called "Chennai" ( a k a Madras) on the southern parts!
How are your studies!
Cheers!
S.K
_________________
Cause something to change, you are not here for ever!
Back to top
View user's profile Send private message Visit poster's website
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Mon Jan 27, 2003 6:55 am    Post subject: Reply with quote

kichu wrote:
GamerZ wrote:
u from India?

Yes!
In a city called "Chennai" ( a k a Madras) on the southern parts!
How are your studies!
Cheers!
S.K
ya so far so good =D
_________________

++ GamerZ.Per.Sg - Complex Simplicity
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Hacks All times are GMT + 1 Hour
Goto page 1, 2, 3, 4, 5  Next
Page 1 of 5

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group