This works! Thanks very much. I understand that with the match method here, you are going through the url to get, I assume, the 3rd occurrence of the “/”, bc the id will always happen after the third “/” in the url, which returns the form “/t/name/id/otherstuff”. Can you provide a little info on how you’re regex does this? It would be very helpful in my regex journey.
Thanks for the info. So it’s the “linked_post_number” that seems to show up some times and throws off my API call. You say here it is “optional”–is there a way to be sure it is never shown?
When a user visits the topic show page, I want to:
- Programmatically know all the tags associated with that topic. Note that some tags are hidden from the user’s view.
- Have a button on the topic page that adds a certain hidden tag to the topic when clicked (if the hidden tag is not there yet), and removes the hidden tag when clicked (if the hidden tag is already there).
This is all straightforward using the Admin API and javascript/jquery (assuming I can get the right topic url to use in the API calls).
I believe the only other way to do this type of thing would be to create a plugin where I get deep into 1. ember, 2. rails and 3. the discourse code base. I’ve reviewed the key discourse posts and docs on how to do this, but I’ve found it slow going bc you really need to understand these 3 pieces. So for now I’ve focused on the API approach.
I’d be interested to hear if there’s another way to do this that would decrease server load.