PDA

View Full Version : Build Post URL from PostID


DivinoZarathos
05-14-2012, 01:10 PM
Hi all!
I'm working on a FORUMDISPLAY modification. I want to add an icon to every threadbit with a link to a post that is on another thread (which is maybe on another forum also). How can I achieve that if I can only use PostID? Is "showthread.php?p=PostID" enough even if the post is located in another thread/forum?
How can I build such a link using fetch_seo_url function or "vb:link thread" without specifying a threadinfo? I'm just trying to avoid adding a very loud query like fetch_threadinfo of fetch_postinfo to just recover external threadid/title for every threadbit I have to process... :confused:

Thanks!

kh99
05-14-2012, 01:32 PM
showthread.php?p=PostID works, but it seems to scroll you to the given post instead of showing the top of the thread. But if you want the seo url then I suppose there's no way to avoid having to get the thread title.

DivinoZarathos
05-14-2012, 01:33 PM
Uh ok! So I'll put something like:
showthread.php?p={vb:raw myvar.mypostid} in my template right?

kh99
05-14-2012, 01:35 PM
If myvar.mypostid gives you the post id, then it look OK to me. Of course you can always see if it works the way you want by entering a url in your browser.

DivinoZarathos
05-14-2012, 01:44 PM
Mhhhh... do you also know how to check if a post still exists from PostID?
I was just thinking about what can happen if the linked post is being deleted...

kh99
05-14-2012, 01:54 PM
You could call fetch_postinfo(postid), check if the return is an array, then check 'isdeleted' to see if it has been deleted. But of course that requires a query (you can see the code for fetch_postinfo() in includes/functions.php).

DivinoZarathos
05-14-2012, 08:02 PM
Thank you!