Info
- 5 posts
- 3 voices
- Started 2 years ago by Tomcraft1980
- Latest reply from zaerl
- This topic is not resolved
How to fix links after increasing "Items per page"
-
- Posted 2 years ago #
Hi there,
is there a way to fix links in posts that look like http://www.domain.org/forum/topic.php?id=5579&page=8#post-56412 after increasing "settings" -> "Reading" -> "Items per page" from 15 to 30?
The problem ist, that the page-numbers will change.
Best regards
Tom
-
- Posted 2 years ago #
Hi. Unfortunately the links obtained from the "#" in Kakumei theme (or similar) are just anchor links. This is due to the fact that they are generated with
post_anchor_link()(file: bb-templates/kakumei/post.php:11).With "just anchor links" I mean that they are anchors (#post-number) of the current page. They aren't permalinks. All that links became invalid once you change the "items per page" (and/or other values) from the bbPress admin panel.
All you can do with the links that users have posted is to parse them and change them accordingly to the new server settings but this can (and will) be a long, tedious, hard and prone to errors work.
I have written a plugin called "zaerl Post Permalink" that solved this problem. My plugin export a function that generate this link:
1) http://www.domain.com/the_bbpress_path/post/post_number
2) http://www.domain.com/the_bbpress_path/?post=post_numberThe (1) is preferred if
mod_rewriteis used. These links are permanent and do adapt on the fly to the actual settings of the server. I use my function in various places of the template and post.php is one of these.I can share my work with you if you want. Email me za AT zaerl.com.
p.s. keep in mind that the plugin isn't retroactive.
-
- Posted 2 years ago #
damn. ;-)
So will your plugin be compatible with bbPress 1.03 or is there another solution already integrated in bbPress 1.03?
Will my old anchor-links stop working after activating your plugin?
Best regards
Tom
-
- Posted 2 years ago #
This could be handled with javascript and (unfortunately) a page reload.
PHP cannot see the hash because it's not sent by the browser to the server.
But javascript can see it.
When the page loads, javascript could look at the hash and then see if an object with that id exists on the page. If not, it could do a proper request from the server via a plugin.
per your example:
http://www.domain.org/forum/topic.php?id=5579&page=8#post-56412
pseudo code:
if (window.location.hash && window.location.hash.substring(0,5)=="post-" && !document.getElementById(window.location.hash)) { document.location="?post="+window.location.hash; }Then on the server side a plugin would look for the post request and return the proper new url.
A little bit messy but would allow backwards compatibility if there are links out there which cannot be fixed, especially on other sites.
WordPress has the same problem with post and comment pagination as the pages constantly move. It's a poor design.
-
- Posted 2 years ago #
So will your plugin be compatible with bbPress 1.03 or is there another solution already integrated in bbPress 1.03?
My plugin works in 1.0.2 which is the official release. When the new bbPress will come (it's in alpha stage right now) I will update it if necessary. Given what I have seen it will work at 99% without changes. At least if devs don't add a '/post/*' rewrite rule.
Will my old anchor-links stop working after activating your plugin?
Yes. That are just links. I don't modify any template function but I just add another way of addressing the posts. Obviously if you deactivate the plugin all the posts permalinks will spawn a 404.
-
You must log in to post.