1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed How do I put a Top link in the posts that doesn't take people to the front page (home).

Discussion in 'Resolved Bug Reports' started by anotheralias, Oct 28, 2010.

  1. anotheralias

    anotheralias Well-Known Member

    Someone kindly wrote me a Mod for a Top link, but those using Google Chrome say it takes them to the forum home rather than the top of the thread.

    So, I tried putting this on the template post, to the right of report:

    <div><a href="{$requestPaths.requestUri}#navigation">{xen[​IMG]hrase top}</a></div>

    (And obviously there's no actual :p in there, but I don't see a code BBcode in the edit form.)

    And it works just fine unless you click it on a post you just posted, (where most people would want to click it), in which case it takes you to this error message:

    This action is available via POST only. Please press the back button and try again.

    Is there any chance anyone knows what to do to fix that?

    Thanks for reading this. :)
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I just tested this. It gives that error because the requestURI of the AJAX-loaded post is the add-reply action. You get a link like this:

    http://www.domain.com/index.php?threads/title.999/add-reply#navigation

    Instead of this:

    http://www.domain.com/index.php?threads/title.999/#navigation

    I don't have a way to account for this, but here is a fix that involves javascript:

    Code:
    <div><a href="{$requestPaths.requestUri}#navigation" onclick="self.scrollTo(0, 0); return false;">{xen:phrase top}</a></div>
    
    I tested this and it works.
     
    anotheralias likes this.
  3. Kier

    Kier XenForo Developer Staff Member

    I'm moving this to bug reports, that's quite an interesting problem you've found there.

    Summary: {$requestPaths.requestUri} on AJAX-fetched data refers to the AJAX page, not the current page.
     
  4. anotheralias

    anotheralias Well-Known Member

    Just like a magic trick, problem solved - thank you so much! :)
     
  5. Edrondol

    Edrondol Well-Known Member

    Not meaning to resurrect a dead thread, but my users have been getting this. It's intermittent and leaves no error message in the log.

    If that code is the key, where exactly would I place it?
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Are you talking about this error?

    This action is available via POST only. Please press the back button and try again.

    This error can be caused by many different things. What are your users doing to trigger this error?
     
  7. Edrondol

    Edrondol Well-Known Member

    Actually they are getting the original error where they click on a post and instead of taking them to a post it takes them to the front page.
     
  8. Edrondol

    Edrondol Well-Known Member

    Or should I say it's happening and no error is generated.

    People have reported it on FireFox and Chrome.
     
  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Can you provide a link where I can see the problem?
     
  10. Kier

    Kier XenForo Developer Staff Member

    If you have a link like this:
    HTML:
    <a href="#top">Top</a>
    ... that will take you to the front page. It's a side-effect of the <base /> tag we use to make friendly URLs work.

    If you want to make a go-to-top link, you need to make it using the {$requestPaths.requestUri} variable, like this:
    HTML:
    <a href="{$requestPaths.requestUri}#top">Top</a>
     
  11. Edrondol

    Edrondol Well-Known Member

    It's very hard to reproduce. The main board area is here. The thread it was reported on is the one labeled "4 Arizona Republicans resign". When you click to go into the thread it takes you to the front page instead of the thread itself.

    Again, I have been unable to reproduce this issue, but I have had several users report this.
     
  12. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Hmm. It's difficult if you can't reproduce the problem.
     
  13. anotheralias

    anotheralias Well-Known Member

    For what it's worth, re the original bug -- people were only having this problem when they clicked the link in their own post. In case that helps with the reproducing at all.
     
  14. Kier

    Kier XenForo Developer Staff Member

    I've sorted out a workaround for this now. The problem should not exist in the next release.
     
    DRE likes this.

Share This Page