Hi, I want to display a pinned topic on my forum that when clicked will redirect to an external URL.
if(window.location.href === "https://x.com/1")
and in both cases it doesn’t work when the topic is clicked on from forum. When clicked it loads the normal topic url… but then if you reload the topic page while already on it, it will then redirect to the external URL
how can i make it work correctly, so that when someone clicks a certain topic it redirects to different URL?
Thank you, I’m enjoying discourse so far!
It looks like you’ll have to change the URL directly for the topic itself in the categories section. Then it should go directly to the external URL - also saving the step of clicking and loading the topic, then clicking on it a 2nd time. Hopefully someone from Discourse will chime in if this would break something in the way categories are listed - and their respective URLs.
Hey, I apologize but I don’t quite understand what you mean. would you mind explaining again the steps to follow?
Sure, no problem.
- First go to the topic you want to have a redirect to external URL in;
- Create a post with whatever text you want along with the external URL;
2a (Optional: If there is a graphic title in the external URL, you can Onebox the URL in your first post which will provide a visual aide to your external link.)
- Pin that post globally (it will always stay at the top of the lists of posts in that topic); and as an option,
- If you do not want/expect any new posts in that topic, Close the topic as well.
This way, you are not likely to break any links to the topic within Discourse, and you have your external URL always at the top when users go to that topic.
Edit: Pinning it globally should also keep that topic at the top of the list when a user clicks on “Latest” as well.