Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 19 Dec 2011, 14:29
Infoman4ever Infoman4ever is offline
 
Join Date: Oct 2011
Question [How to] include a code within templates using a plugin or from another template

Hi,
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.
Reply With Quote
  #2  
Old 20 Dec 2011, 13:17
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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.
Reply With Quote
  #3  
Old 21 Dec 2011, 16:50
Infoman4ever Infoman4ever is offline
 
Join Date: Oct 2011
Great! that what I was looking for, thanks.
Reply With Quote
Reply



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 23:22.

Layout Options | Width: Wide Color: