Author |
Message |
dogs and things Board Member
Joined: 18 Nov 2008
Posts: 628 Location: Spain
|
Posted: Tue Dec 04, 2012 3:49 pm Post subject: Re: Reverse Pagination on Viewforum?? |
|
|
This MOD might be useful for your board.
It adds a select dropdown box to the pagination.
Code: | #################################################################
## Mod Title: Goto specific page
## Mod Version: 1.0.0
## Author: mkiefer <mkiefer@earthlink.net>
## Description: Adds a drop-down list to the pagination whenever more than 5 pages are available. This allows users to jump to page #s which may not otherwise be displayed (because "..." may be used instead.
##
## Installation Level: Easy
## Installation Time: 1-2 Minutes
## Files To Edit: includes/functions.php## Included Files: N/A
#################################################################
##
#################################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
#################################################################
#
#-----[ OPEN ]------------------------------------------
#
includes/functions.php
#
#-----[ FIND ]------------------------------------------
$page_string = $lang['Goto_page'] . ' ' . $page_string;
#
#-----[ REPLACE ]----------------------------------------------
#
/// --- BEGIN MOD: Goto specific page
if ( $total_pages > 5 )
{
$select_page = ' <select name="generate_pagination" onChange="if(this.options[this.selectedIndex].value != -1){ window.location = this.options[this.selectedIndex].value; }">';
for($i = 1; $i <= $total_pages; $i++)
{
$selected = ( $i == $on_page ) ? ' selected="selected"' : ''; // highlight current page by default
$select_page .= '<option value="' . append_sid($base_url . "&start=" . ( ( $i - 1 ) * $per_page ) ) . '"' . $selected . '>' . $i . '</option>';
}
$select_page .= '</select>:';
}
else
$select_page = '';
/// --- END MOD: Goto specific page
$page_string = $lang['Goto_page'] . $select_page . ' ' . $page_string;
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
|
See it in action here, at the right bottom. _________________ phpBB2 will never die, I hope! |
|
Back to top |
|
|
JLA Board Member
Joined: 30 Apr 2009
Posts: 451 Location: U.S.A
|
Posted: Tue Dec 04, 2012 4:42 pm Post subject: Re: Reverse Pagination on Viewforum?? |
|
|
We already have that mod installed and I believe it is where we are stuck.
We've been successful in displaying reverse pagination but there are a couple of small issues
Here is where we are at and existing issues
Forum with only 1 page - No issue except page X of XXX text still displays old numbers
Forum with less than 10 pages -No issue except page X of XXX text still displays old numbers
Forum with more than 10 pages - No issue except page X of XXX text still displays old numbers
Forum with more than 100 pages:
Normal pagination numbers appear as expected (reverse display) but the type in selection box from the mod you mentioned still displays the old pagination number (as does the Page X of XXX)
This is the code from that mod that is related to that. You can see that it was able to be changed for forums with less than 100 pages but for more than 100 pages, it is unclear as to what should be changed to achieve the same results
Code: |
/****************************************
* MOD: Pagination Select List & Input Box
****************************************/
// BEGIN : BEFORE, ADD
if ( $total_pages > 10 )
{
if ( $total_pages < 100 )
{
$select_list = '<select onChange="if (this.options[this.selectedIndex].value != -1) { window.location.href = this.options[this.selectedIndex].value; }">';
for ($i = 1; $i <= $total_pages; $i++)
{
$select_list .= '<option value="' . append_sid($base_url . "&start=" . ( ( $i - 1 ) * $per_page ) ) . '"' . ( ( $i == $on_page ) ? ' selected="selected"' : '' ) . '>' . ($total_pages + 1 - $i) . '</option>';
}
$select_list .= '</select> <br> ';
$input_box = '';
}
else
{
$input_box = '<input type="text" size="7" value="'.$on_page.'" onKeyPress="var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode; if ( keyCode == 13 ) { var page_no = parseInt(this.value, 10); if ( !isNaN(page_no) && page_no <= '.$total_pages.' && page_no > 0) { var start = String((page_no - 1)*'.$per_page.'); window.location.href = \'' . append_sid($base_url . '&start=\'+start+\'') . '\'; return false;} else { this.value = '.$on_page.'; return false;} }" /> <br> ';
$select_list = '';
}
}
else
{
$input_box = '';
$select_list = '';
}
$page_string = $input_box . $select_list . $page_string;
// END : BEFORE, ADD
$page_string = $lang['Goto_page'] . $select_page . ' ' . $page_string;
return $page_string;
}
|
_________________ http://www.jlaforums.com |
|
Back to top |
|
|
Salvatos Board Member
Joined: 19 Feb 2009
Posts: 449 Location: Québec
|
Posted: Tue Dec 04, 2012 6:39 pm Post subject: Re: Reverse Pagination on Viewforum?? |
|
|
Instead of displaying $on_page, use ($total_pages + 1 - $on_page) like the other bits do with $i?
Code: | $input_box = '<input type="text" size="7" value="'.($total_pages + 1 - $on_page).'" onKeyPress="var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode; if ( keyCode == 13 ) { var page_no = parseInt(this.value, 10); if ( !isNaN(page_no) && page_no <= '.$total_pages.' && page_no > 0) { var start = String((page_no - 1)*'.$per_page.'); window.location.href = \'' . append_sid($base_url . '&start=\'+start+\'') . '\'; return false;} else { this.value = '.$on_page.'; return false;} }" /> <br> ';
|
I don't know where the "page X of XXX" string is generated but I suppose the same applies. |
|
Back to top |
|
|
JLA Board Member
Joined: 30 Apr 2009
Posts: 451 Location: U.S.A
|
Posted: Wed Dec 05, 2012 6:19 pm Post subject: Re: Reverse Pagination on Viewforum?? |
|
|
Salvatos wrote: | Instead of displaying $on_page, use ($total_pages + 1 - $on_page) like the other bits do with $i?
Code: | $input_box = '<input type="text" size="7" value="'.($total_pages + 1 - $on_page).'" onKeyPress="var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode; if ( keyCode == 13 ) { var page_no = parseInt(this.value, 10); if ( !isNaN(page_no) && page_no <= '.$total_pages.' && page_no > 0) { var start = String((page_no - 1)*'.$per_page.'); window.location.href = \'' . append_sid($base_url . '&start=\'+start+\'') . '\'; return false;} else { this.value = '.$on_page.'; return false;} }" /> <br> ';
|
I don't know where the "page X of XXX" string is generated but I suppose the same applies. |
Thanks very much. Ok, with your suggestion and one other change (see this)
Code: |
$input_box = '<input type="text" size="7" value="'.($total_pages + 1 - $on_page).'" onKeyPress="var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode; if ( keyCode == 13 ) { var page_no = parseInt(this.value, 10); if ( !isNaN(page_no) && page_no <= '.$total_pages.' && page_no > 0) { var start = String((page_no - 1)*'.$per_page.'); window.location.href = \'' . append_sid($base_url . '&start=\'+start+\'') . '\'; return false;} else { this.value = '.($total_pages + 1 - $on_page).'; return false;} }" /> <br> ';
|
The result we have with forums with over 100 pages
* Page number displayed in goto box corresponds with page number displayed in pagination string line.
*When typing in a page number into the goto page box, (say for example in a 386 page forum)
Type in page 384 it goes to second from last forum page (page 3 on the pagination string) and then the goto page box then displays page 3. If you click on page 384 of pagination string, it then goes to 3rd forum page (correct behavior) and displays page 384 in goto page box (correct behavior)
So it looks like that just need to determine on how to correct when typing a number in goto page box it will go to the correct corresponding page in the pagination string and display this page in the goto page box upon arrival. _________________ http://www.jlaforums.com |
|
Back to top |
|
|
Salvatos Board Member
Joined: 19 Feb 2009
Posts: 449 Location: Québec
|
Posted: Wed Dec 05, 2012 6:48 pm Post subject: Re: Reverse Pagination on Viewforum?? |
|
|
If I'm following, I think you have to "invert" your JS variable 'start' similarly. Something like this?
Code: | var start = String(('.$total_pages.' + 1 - page_no)*'.$per_page.' |
|
|
Back to top |
|
|
JLA Board Member
Joined: 30 Apr 2009
Posts: 451 Location: U.S.A
|
Posted: Wed Dec 05, 2012 9:34 pm Post subject: Re: Reverse Pagination on Viewforum?? |
|
|
Salvatos wrote: | If I'm following, I think you have to "invert" your JS variable 'start' similarly. Something like this?
Code: | var start = String(('.$total_pages.' + 1 - page_no)*'.$per_page.' |
|
Ah, thanks. That was just about it. Was coming up 1 page off. made a small change and now that part works.
Code: | var start = String(('.$total_pages.' - page_no)*'.$per_page.' |
Looking good with that...
Now, I'll take a look at the Page XXX of XXX (think it is generated on viewforum) to see how to get that one corrected.
Thank You again _________________ http://www.jlaforums.com |
|
Back to top |
|
|
JLA Board Member
Joined: 30 Apr 2009
Posts: 451 Location: U.S.A
|
Posted: Wed Dec 05, 2012 10:01 pm Post subject: Re: Reverse Pagination on Viewforum?? |
|
|
Ok, so it looks like the Page XXX of XXX is generated in viewforum here
Code: | 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $topics_count / $board_config['topics_per_page'] )),
|
Change it to this
Code: | 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( ($topics_count - $start) / $board_config['topics_per_page'] +1 )), ceil( $topics_count / $board_config['topics_per_page'] )),
|
_________________ http://www.jlaforums.com |
|
Back to top |
|
|
|