Welcome Guest, Not a member yet? Register   Sign In
Forum topics pagination and posts anchors
#4

(This post was last modified: 03-13-2015, 12:03 PM by mwhitney. Edit Reason: Additional information about paging )

The word permalink was correct if you're looking to do the same thing done on this forum. Take a look at the URL you gave for my post:
http://forum.codeigniter.com/thread-1466...ml#pid6575

Now, this forum uses MyBB, but I'll break down the existing URL and give an example of how this might be done in CI:
MyBB: http://base_url/thread-{threadID}-post-{...pid{postID}
CI:   http://base_url/thread/{threadID}/post/{...pid{postID}

The paging of the forum is not mentioned in the URL for the post because it is not relevant. The page numbers are only referenced when you are viewing a list of threads or a paged list of responses to a post. For example, the following URL does not mention a page, even though the post it references is on the second page of a discussion:

http://forum.codeigniter.com/thread-1380...ml#pid6437

However, the following link may appear to take you to the same place:
http://forum.codeigniter.com/thread-1380-page-2.html

It references the page because the link is to the second page of the thread, not to the specific post.

[EDIT: If you change your options on the forum to display 20 posts per page (instead of the default 10), the first link will take you to the 11th post on the first page instead of the first post on the second page, while the second link will just take you to the first page, unless the thread gets up to 21 posts]

If you look at the code for the page you are currently viewing, you will find that there is a div with an id which matches the portion after the # in the URL (the easiest way to see this is to right-click on the header with the post author's information and select "Inspect Element", the div will be one of the divs surrounding the one which is selected in the inspector). This is what causes the page to focus on the post once the page is loaded. If I were to go to http://forum.codeigniter.com/thread-1380-post-6437.html (instead of http://forum.codeigniter.com/thread-1380...ml#pid6437 ) the page still loads properly, but the browser's focus is not moved to the top of the post.
Reply


Messages In This Thread
RE: Forum topics pagination and posts anchors - by mwhitney - 03-13-2015, 11:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB