Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-12-2010, 04:43 PM
Killerhands Killerhands is offline
 
Join Date: Mar 2006
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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:
Code:
Please go to the FAQ and Clan Knowledge forum if you have any questions or need to find information about the clan.
Auto-detected forum post
Code:
Please go to the FAQ and Clan Knowledge forum if you have any questions or need to find information about the clan.
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 09-12-2010, 05:22 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 https://vborg.vbsupport.ru/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 09-13-2010, 02:23 PM
Killerhands Killerhands is offline
 
Join Date: Mar 2006
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 09-13-2010, 02:43 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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


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

Forum Jump


All times are GMT. The time now is 07:40 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03580 seconds
  • Memory Usage 2,188KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete