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

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
tongue.png
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. :)
 
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.

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.
 
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.
 
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.

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?
 
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?

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?
 
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.
 
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.
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>
 
Can you provide a link where I can see the problem?

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.
 
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.
 
I've sorted out a workaround for this now. The problem should not exist in the next release.
 
Top Bottom