How to Extract Post or Thread ID from Form Input?

Alteran Ancient

Well-known member
Exactly as it says on the tin. I am working on an in-house modification, where I want to be able to associate a Post ID or Thread ID with an object. Now, I could just take this straight off the user as a plain ID number, but where would the fun be in that?

Essentially, user is completing a form, and the field concerned would look a little bit like this...

"Associated Post/Thread URL: http://mysite.com/threads/some-thread-i-made.9096"

I want to be able to extrapolate whether the user is submitting a /posts/123456 link, or a /threads/9096 link, and then process this and do whatever I need to do with that result.

Seeing as the forum already matches these URLs when you're playing around with your browser's address bar, it can't be too hard to tap into a pre-existing XenForo Route controller somewhere and do this, surely?

Cheers.

Update: I kinda found a way to do this break-down the URL with PHP's parse_url function and then pick-apart the resulting mess. It's probably not the right way with all the functions that XenForo has to offer, but it's a step in the right direction until someone comes up with a better solution.
 
Last edited:
Top Bottom