Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Previous and Next Links for Page Index

Started by phpmycoder, January 22, 2008, 11:23:32 PM

Previous topic - Next topic


Link to Mod

Creates Previous and Next Links for Page Index (for long topics)

For example:

Prev 1 2 3 [4] 5 Next

[1] 2 3 4 5 Next

Prev 1 2 3 4 [5]



Works great, shouldn't this be standard in SMF?  :)

Thanks a lot!  :D
I'm using SMF 2.0.2 and SimplePortal 2.3.4



Nice mod!

People on my site kept saying it was hard to change pages, since all other forum software has the prev next links.


Quote from: Neg1 on January 25, 2008, 07:04:49 AM
it was hard to change pages, since all other forum software has the prev next links


and thanks for all the kind words :)


Happily using a heavily modified 1.1.16 version of SMF!

2748011 Posts in 320998 Topics by 50986 Members

SOLD my website - thanks it was a good run - they converted to vbadvanced. (and screwed it up good!)


I think you should replace next and prev with > and < because this is more international than the two words. And i think you should add a >> and << for last and First Page, only a thought but i think this would made the mod much more better =).

Support only via MOD Thread! NO PM Support!
My Forum: ayu][kult Forum
My Mods: My Small Mod Collection
My Parser: DIN1031's ModParser
Current Info: More away the next days, because i've to much work to do :x


proud member of (forum)


Mod update (v2):

- Supports SMF 2.0.2 (although code stays the same..)

- "Prev" and "Next" strings are now in the language files.


Shows "Next" in the message index. Doesn't seem like expected behavior... so I'm reporting it.


These edits will fix the issue:


Code (Find) Select
function constructPageIndex($base_url, &$start, $max_value, $num_per_page, $flexible_start = false)

Code (Replace with) Select
function constructPageIndex($base_url, &$start, $max_value, $num_per_page, $flexible_start = false, $show_prev_next = true)

Code (Find) Select
$pageindex = sprintf($base_link, $tmpStart, $txt['prev page']);

Code (Replace with) Select
if ($show_prev_next) $pageindex = sprintf($base_link, $tmpStart, $txt['prev page']);

Code (Find) Select
$pageindex = sprintf($base_link, $tmpStart, $txt['next page']);

Code (Replace with) Select
if ($tmpStart <= $tmpMaxPages && $show_prev_next) $pageindex = sprintf($base_link, $tmpStart, $txt['next page']);


Code (Find) Select
$pages .= constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false);

Code (Replace with) Select
$pages .= constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false);


Thanks for the fix, live627! I had some trouble with two of your changes, so this is what worked for me (I made these changes after installing the modification):

First two changes in ./Sources/Subs.php were fine.

For the third change in ./Sources/Subs.php, I did instead:

Code (find) Select
if ($tmpStart <= $tmpMaxPages) $pageindex .= sprintf($base_link, $tmpStart, $txt['next page']);

Code (replace with) Select
if ($tmpStart <= $tmpMaxPages && $show_prev_next) $pageindex .= sprintf($base_link, $tmpStart, $txt['next page']);

For ./Sources/MessageIndex.php, I did instead:

Code (find) Select
$pages .= constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true);

Code (replace with) Select
$pages .= constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false);

Also thanks to phpmycoder for the original modification :]


Sorry for late reply, I subscribed here with an email I hardly check anymore, but should attend often now.

- Fixed the issue above by adding !$start_invalid condition.
- Beautified code (just for show, no practical implication).
- All changes still only in Subs.php

If there's any new or old problems popping up please let me know and I will try to attend asap.

All the best,


Hi I've been having a problem with this mod, I've installed it via the admin/package manager. and I noticed no options for it, nor was it showing on any pages as if it was working. So I removed it assuming it isn't working, after I removed it, I realized that my font size has increased and now at the top of the page you can see "// PreviousNextPage links $txt['prev page'] = 'Prev'; $txt['next page'] = 'Next';" So I proceed to see if installing and uninstalling it again would work, but no luck, instead, it shows that msg twice on the top of my page. If you'd like to have a look, check [nonactive] I'm no type of coder, I'm fairly new to all of this, but I believe this can be a bug when installing it through the package manager, any help you guys can give me to fix this issue? Thanks in advance.


There are no settable options for this mod. About package manager - have you tested the installation before actually installing? Package manager has a test function where you can see if installation was successful or not before real changes are committed. Most likely this would have returned an error, meaning that it conflicts with other mods (other mods that are already installed have modified the same segments of code, and therefore the package manager cannot install or remove the code segments accurately). So you have to restore your site from a backup, then locate the other conflicting mods.

One Quarter

This mod does not appear to work with my forum (2.0.4).  I get a parse error message when trying to install the package, and manual installation does not appear to do anything.  Any ideas?


I just tested the mod on a fresh 2.0.4 installation and it installs ok. Please see my post above, it may be conflicting with other mods you installed or with other custom changes in the code.

Can you post exactly which parse error you are getting, that may give a hint as to the specific problem you are experiencing. Also can you attach the php file the error emanates from.

One Quarter

Installation Readme
Warning! This mod has not been tested on your specific installation of SMF. Do not proceed if you get 'Test Failed' messages! Available Readme Languages: 

Installations actions for "Previous and Next Links for Page Index"
Installing this package will perform the following actions:
Type   Action   Description
1.   Execute Modification   modification.xml   Modification parse error
2.   Execute Modification   modification.xml   Modification parse error


Regarding the warning, I have changed the mod so to imply it supports 2.0.4. You can download the new version from the mod page ( )

Regarding the parse error, please first try installing the mod on a fresh SMF installation (no other mods). There is probably another mod which modified the same segment of code and therefore the modification isn't being applied as it should.