vBulletin Mods

The Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=250373

Hotlinking Forum Names In Posts?
by Killerhands
12 Sep 2010 17:43

Hi everyone,
I know the basics about vB and have edited a few templates and code here and there, but nothing major. So, I was thinking the other day that if someone posted a thread (or reply) if within the text they reference a Forum, instead of manually having to make a hyperlink linking the text to the forum if somehow vB would auto-detect the name and hotlink it automatically.

Here's a more visual explaination:
original post:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Auto-detected forum post

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I'm not exactly if this is even possible, but I was wondering if any of you coders out there would have any information about how to approach this. I've looked for mods and I haven't seen anything like this (AME is the closest). I'd imagine it'd just be some sort of simple If-then-else set of statements coming from basic coding experience but I'm not sure on specifics.

Any insight would be greatly appreciated!:)

Thanks,
Killerhands

kh99 12 Sep 2010 18:22

Yeah, seems like you could do that without a lot of trouble. The forum names are already in memory (although it may depend on which php file is being executed, I'm not sure). You'd just need to find the right hooks to do a search and replace on the text. Would you want it to be before it's stored or just before it's displayed? I'd think before it's stored so that if a forum is renamed the link would still be there. Some one just asked about that recently, I think I found that the newpost_process hook is called before a post is stored in the database, but that doesn't work on posts being edited (the thread is http://www.vbulletin.org/forum/showthread.php?t=250140).

Maybe another way would be to replace the forum name with some bbcode like [forum]123[/forum], then define a bbcode to provide a link (although I guess you couldn't just define a bbcode using the manager, you'd have to write a plugin to be able to insert the forum's name).

Hope some of this make sense.

Killerhands 13 Sep 2010 15:23

The bbcode makes the most sense, just I think the hard part for me if figuring out how to extrapolate the forum ID based on the text. I just don't really know where to start. Would I have to make a query to the database asking for all the forum names listed within it and do a search from that?

kh99 13 Sep 2010 15:43

A while back I knew a lot about this because I was working on somethng that used the forum info, and now I've forgotten. Maybe the best thing is to look at forumdisplay.php (and also be prepared to look into any included files to see where stuff comes from, like init.php and global.php).

A lot of stuff gets cached to avoid doing a lot of database queries. For instance, the forum info gets used a lot, so once the query's been done the array is serialized and saved as a big string to avoid doing a complex query every time someone vists the home page. There's a $vbulletin->forumcache that's an array by forum id, and one of the fields is 'title', so $vbulletin->forumcache['12']['title'] should be the name of forum with id 12. There's also a variable called $foruminfo, I can't remember what that's for. You'll have to investigate to see under what circumstances these things are filled in (or maybe someone else can help).


All times are GMT. The time now is 23:59.

Powered by vBulletin® Version 3.8.14
Copyright © 2021, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.