vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   How to use the plugin system to make template edits? (https://vborg.vbsupport.ru/showthread.php?t=262839)

jwocky 04-29-2011 10:07 AM

How to use the plugin system to make template edits?
 
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!!

kh99 04-29-2011 02:34 PM

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:

Code:

$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. :)


All times are GMT. The time now is 08:18 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00937 seconds
  • Memory Usage 1,711KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete