vBulletin Mods

The Official vBulletin Modifications Site

[How to] include a code within templates using a plugin or from another template
by Infoman4ever
19 Dec 2011 14:29

I know now how to create a plugin and link it to a hook, and how to create a template and put it "manually" on an existing template, but what I don't know yet is how to put a piece of code from a plugin or from a template "created manually" on a specific place within an existing template such as the posbit, posbit_legacy, showthread and so on. I need to do it to create a general product, right?
Well, I tried using hooks, but sometimes they do not help, they do not cover some places within some templates.
Any help will be highly appreciated.

kh99 20 Dec 2011 13:17

I was hoping someone else could answer who might be able to explain better, but...

You need to do a str_replace() (or equivalent) on $vbulletin->templatecache['template_name'], and it has to be at a hook location where the templates have been cached but not rendered yet. Location parse_templates should work. Also, you need to look at the compiled template to see what you can match as the "needle" in str_replace(). It may or may not be the same as you see when you look at the template in the template editor. To see the compiled template, look in the "template" table of the database in the "template" column, or print out the value of $vbulletin->templatecache['template_name'].

So when you've done all that your code could look something like:

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

Note that most compiled templates are actually php code that produces the template html when eval'd, so you could also insert php code into the template is you wanted.

Infoman4ever 21 Dec 2011 16:50

Great! that what I was looking for, thanks.

All times are GMT. The time now is 03:52.

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.