![]() |
|
Mod Options |
![]() |
|||||||||||
Let PHP Live! (Allow PHP code in templates)
![]() Developer Last Online: Jul 2011 ![]() ![]() ![]() This modification is in the archives.
I got frustrated that the vBulletin template system limited me in this way so... I wrote a hack around it.
Just use <? <?php <?= as you would normally in the templates. I'd like to see PHP based templates in the future, vBulletin! <if> is useless if I can just type <? if ?> ! Things to Remember You cannot break up PHP blocks. <? if (0): ?> Hello!!! <? endif ?> will not work, and you'll get a nice error message about how it didn't. If it's really a concern for anyone, I can try to get it working. In my opinion, that's not a big deal. I think PHP support sans breaking up blocks in 10 lines of hack code is pretty nice, myself. That's a limitation of eval anyway ![]() Variables aren't always the same in PHP mode! While you can use $vboptions[bbtitle] in your main code and get it working, vBulletin is doing behind the scenes voodoo on stuff. To access $vboptions[x]: $GLOBALS['vbulletin']->options['x'] Download Now Only licensed members can download files, Click Here for more information. Show Your Support
No members have liked this post.
|
![]() |
||||
Mod | Developer | Type | Replies | Last Post |
BB Code Enhancements MLG Live Event BB Code | fattony69 | vBulletin 3.7 Template Modifications | 0 | 13 Jul 2008 04:41 |
BB Code Enhancements Live Video Embed BB Code | InTeNsE-HuMoR | vBulletin 3.6 Add-ons | 4 | 13 Jun 2007 18:23 |
Comments |
#2
|
||||
|
||||
Interesting, Ill wait untill someones got this working though
No members have liked this post.
|
#3
|
|||
|
|||
Thanks for sharing.
No members have liked this post.
|
#4
|
|||
|
|||
Originally Posted by leestrong7
Not much to get working... you import the XML file, the end. Nothing to configure. Code only runs when templates are compiled.
No members have liked this post.
|
#5
|
|||
|
|||
hm.... intresting..... installed....
No members have liked this post.
|
#6
|
|||
|
|||
Damn, could have used this when I was struggling to get some PHP scripts to work with 3.6 in the beginning, lol.
I'll still take this for a spin for when I next need to do some PHP stuff. Thanks! No members have liked this post.
|
#7
|
||||
|
||||
I think, as probably do the vB Coding Team, that the ability to use PHP in Templates is a Security Risk. What if you've got an Administrator on your board who gets bored and decides to execute some harmful code?
__________________
Former vBulletin.org Staff Member Please feel free to re-use any of the code in any of my projects submitted to vB.org, so long as original attribution is retained. ![]() No members have liked this post.
|
#8
|
||||
|
||||
Originally Posted by acidburn0520
I do not put people in power who I can not trust.
Do you ? If you do, make sure you back up. No members have liked this post.
Last edited by Zachariah; 16 Aug 2006 at 22:12. |
#9
|
|||
|
|||
awesome, i only tested with a simple echo statement but it worked like a charm :yesway:
No members have liked this post.
|
#10
|
||||
|
||||
Originally Posted by Zachariah
I trust all my Administrators. But just because you trust someone doesn't mean that they wouldn't for some reason get upset and retaliate.
__________________
Former vBulletin.org Staff Member Please feel free to re-use any of the code in any of my projects submitted to vB.org, so long as original attribution is retained. ![]() No members have liked this post.
|
#11
|
||||
|
||||
I'm sure there was a very good reason php was not allowed in templates, and it's never necessary if stuff is written properly. Still, nice of you to share.
![]()
__________________
Former vBulletin.org Staff Member
Cable Forum Please do not PM me about custom work - I no longer undertake any. Note: I will not answer support questions via e-mail or PM - please use the relevant thread or forum. No members have liked this post.
|
#12
|
|||
|
|||
I'm pretty sure it's annoying when software intentionally tries to limit the administrator. If you have a huge problem, remove Styles Permissions in the administrator permissions for the administrator you cannot trust. All of my admins also have FTP access and have been in my community for 5 years, I would trust them with babysitting my children. If you cannot trust your administrators, then who can you trust? They have access to all of your board. They could delete all of that board. I guess it is a security risk to have administrators at all. :/
However, it is not good to assume that all situations can be solved by saying "well, if it was written RIGHT then this wouldn't be necessary." This is a nice shortcut for anyone who actually wants to turn vBulletin into something else besides a stock vBulletin with a different logo and color scheme. Here is my situation and the reason I wrote this particular hack: I wanted to integrate the header and footer which vBulletin uses with the rest of my site's template system. I do this by calling top() and bottom() when I need the header and when I need the footer respectively. Since each template has different values that I will need to pass to top() for the navigation selection, title, necessary <head> elements, etc I will need to replace the HTML code that starts every template with a call to top(). Saying that I could just put this in $header is ridiculous- vBulletin itself does not do that. What am I supposed to do? Make a plugin for every single _start of a document? That's also ridiculous, and also hard to maintain. I know separating code and display is the hot new thing to do, but that doesn't mean you should have to go out of your way to do it. Personally, I like being able to include template files and use PHP formatting logic to echo stuff directly into templates without being assed to make a plugin in some far away part of the CP. vBulletin template support is poor; it needs this. ![]() Thanks to everyone who installed! No members have liked this post.
Last edited by King Internet; 17 Aug 2006 at 02:35. |
#13
|
|||
|
|||
FINALLY - thanks
![]() I need it for certain gameserver stuff which was a pain before. I mean yes, you can call php files using a nice neet plugin and such, but this makes it sooo easier - thanks /me clicks install No members have liked this post.
|
#14
|
||||||||
|
||||||||
can I get a "this hack for dummies" post? How exactly does this work?
I want to put this php code in my header:
The reason - mysite.com and forums.mysite.com are on two different servers. *EDIT* Is it as easy as using this:
????
__________________
see sig. No members have liked this post.
Last edited by wolfyman; 18 Aug 2006 at 22:41. |
#15
|
||||
|
||||
I installed and works perfect.. <!- / thank you - >
No members have liked this post.
|
![]() |
«
Previous Mod
|
Next Mod
»
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Mod Options | |
|
|
New To Site? | Need Help? |
All times are GMT. The time now is 17:53.