0
votes

I made pagination with PHP and jQuery for topic+entry project

Lets say a topic has five pages. I made a refer system if my user write "@5" in 10th post and another user clicked @5, page slide up to 5th comment. But I don't know how to refer to if user write "@5" in 20th post. page may not find that div because 5th post is at 1st page, and my pagination per page limit is 15 and I have 5 pages.

What am I supposed to do? Maybe I can calculate fifth post is in the first page and make a chain events in jQuery: go to first page and slide to fifth post etc I don't know that is.

1
"i" is always capitalized when referring to yourself. This is one of the most straight forward rules in English and it goes a long ways towards making your posts more readable.meagar
well I did write every "i" that is referring to myself as Capitalized or am I mistaken O_oEjderha Katili
No, I edited your post to fix all the spelling mistakes. Most of them were written "i". I was hoping you would do better with your next post so somebody doesn't have to edit it.meagar
oh :) I am so sorry, I got turkish Q keyboard so I have got both "ı" and "i" it makes a little confusion :)Ejderha Katili

1 Answers

1
votes

You can use the same method than stackoverflow uses to link answsers: you provide in the url the id of the page, and the id of the specific answer (or comment, in your case). And your php script, when it sees this format of url, thansforms the url with an html anchor.

For example: http://yoursite/question_id/comment_id is redirected to site/question_id#comment_id

You can test it on this very answer by clicking this link: https://stackoverflow.com/a/10027770/311744. This url provides enough information so that the server redirects to the correct page (the current page in this case), with the anchor to this answer (#10027770).

Then you can handle manually the special case where the comment is on the current page and prevent the reload of the same page with javascript (but I woudn't bother, and SO doesn't either)


Edit: What I understand is that you want to be able to click on "@5" written on a user comment, and this comment should somehow be displayed. At this point you have two solutions:

  • You redirect to the page where you can find the comment (and if this comment is on another page, you should load the page. This is what I explained before.
  • You can just load the comment below the comment where the reference is, just like youtube does when you load reply to comments. (on this youtube page you have some top comments with replies that you can test)