vBulletin Mods

The Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=314677

Add PHP to your Templates (Trick)
by TheAdminMarket
02 Oct 2014 16:56

First of all, let's make clear something. Yes, (unfortunatelly) vBulletin does not allows PHP in templates. But don't stuck on this. Extend your imagination. "If you can't go left, go right. Just don't stand" :)

The solution for this problem is much more easier than you can think. "If you can't add PHP in the templates, add templates to PHP" :) You just need a "echo" command in your PHP file. Yes it's so simple, the result will be exactly what you want, and most important, you can use vboptions, vbphrases, datamanager and everything you want.

1.- Create a template for Header:


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




Remark:
If you want to make use of vB sidebar in your page, you must add within head section:


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




2.- Create a template for Footer:



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

3.- In your PHP file (assuming that is a file which loads all vB functions that you need), add (again is an example):


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

............Here you can add any PHP code that you like..............


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

As you can see you can use ANY vB template in the PHP file. Just assign it to a variable and then use echo to show it in the screen.

Hope that this short tutorial will be useful to those who have stuck with this vB limitation. I love to use the Smarty template engine with PHP.

abdobasha2004 31 Oct 2014 02:45

That is a way I searched for a lot!
Thanks Nick

Linhnt 31 Oct 2014 08:45

For What?

TheAdminMarket 31 Oct 2014 08:47

Quote:

Originally Posted by Linhnt (Post 2520721)
For What?

For what it needs? Just a word can explains it: AJAX


All times are GMT. The time now is 04:07.

Powered by vBulletin® Version 3.8.14
Copyright © 2020, 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.