View Full Version : How to use the plugin system to make template edits?
jwocky
04-29-2011, 10:07 AM
I know my way around the vbulletin hooks system and PHP, but I never figured out how to use the plugin system to actually insert data into the HTML templates. I know this is possible as I see some mods do it? Can anyone help me with the basics on how to use the plugin system to make template edits?
thanks!!
Well, if you just want to insert something you can put any variable name you want in the template and make sure it's set in a plugin (before the template is eval'ed of course). But one issue is that some templates are eval'ed in a function, so global variables aren't available unless there's a "global" statement for it in that function. I guess one solution to that is to use an existing global array that you know will be available (like $vbulletin->userinfo), but that's kind of a hack. I don't know if there's an "approved" way. There is a template_hook[] global that is already inserted at certain points in some templates, so maybe that would be a better solution, but I don't know if that's "global" everywhere a template is eval'ed or not.
If you want to delete or alter something that's already there you can do a str_replace (or whatever) on it with something like:
$vbulletin->templatecache['template_name'] = str_replace("search", "replace", $vbulletin->templatecache['template_name']);
although in some situations it can be tricky to know what to match, like we were discussing in this thread a while back: https://vborg.vbsupport.ru/showthread.php?t=255738
Anyway, I hope this helps. I'm certainly not anything like the resident expert on this but I'm sure someone else will add to this or correct me if ncessary. :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.