Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 12 Sep 2010, 17:43
Killerhands Killerhands is offline
 
Join Date: Mar 2006
Hotlinking Forum Names In Posts?

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
Reply With Quote
  #2  
Old 12 Sep 2010, 18:22
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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.
Reply With Quote
  #3  
Old 13 Sep 2010, 15:23
Killerhands Killerhands is offline
 
Join Date: Mar 2006
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?
Reply With Quote
  #4  
Old 13 Sep 2010, 15:43
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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).
Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mini Mods Signed Posts (Nick names addon) Roms vBulletin 3.6 Template Modifications 15 05 Jun 2008 01:37
Signed Posts v2.0, Nick names Roms vBulletin 3.5 Template Modifications 7 31 May 2006 03:13



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 09:09.

Layout Options | Width: Wide Color: