![]() |
Embed PHP in Templates
This hack lets you embed PHP code in templates. Simply add your code between a <? (not a <?php) and ?> tag and it will be eval'ed. All variables will be referenced in the global scope.
If you're using my Usergroup Tags in Templates hack then you're going to have an extraordinarily difficult time installing this hack. However the clever hacker can tell what has changed in this version. You can somewhat use this to do conditionals in templates. Theoretically, this will work: Code:
template... This hack also enhances the comments delimiting templates (if that option is turned on) to include the character count and PHP block count of the specified template. |
Admin CP:
|
The result:
|
I'm definately going to use this when I get back :) Thanks for the hack filburt!
|
Wow, this leaves all the template conditional hacks in the dust. I might even install this one!
Great job, filburt! |
Very nice filby! Is this efficient?
|
I dont think effecient is the way to put it, its only as effecient as the code u put between the tags....if u just put <? ?> or <? // ?> its not gonna slow anything down a bit...
|
What are the limitations on the use of PHP ?
- miSt |
Mist, as far as I know, I don't think there are any, as the example that Filburt gives with the if condition statement looks like proper PHP so by the looks of that, a lot can be done.
|
Thank you very much... i try to use this script
|
N9ne - its called a ternary operator i believe ;)
I'm very interested to see how this develops as IMO i think we'll see a lot of PHP errors popping up now on vBulletin.org due to poor PHP coding in the templates :) - miSt |
Quote:
|
awesome! will install! i've been wanting this for awhile now!
|
nice work
:) All-the-vb click install |
Pseudo-code of what it does:
1. Find every occurance of <? and ?> (and what's inbetween them) 2. For each occurance, make every variable within in the global scope, and then eval what's in the occurance 3. Remove the original occurances from the template. |
And so, no need to modify PHP files to create new hack (even if I'll continue to modify the php files for my new hack, but this can be usefull for some modifications ;) )
[high]* grog6 cliks install too :) [/high] Thx for it Filburt |
Very nice filby;):)
Satna |
Very nice, thanks! :bunny: :banana:
|
nice hack, I fixed it slightly though to suit my needs:
PHP Code:
<? ?> <?php php?> <php></php> and any combinations of them, such as: <?php ?> and so on. Also now if you use return(stuff here); in the php script, it returns the data straight to the template itself. Like: <? $stuff = "stuff"; return $stuff; ?> would return the $stuff varible right into the template for you. |
Odd... the following code doesn't seem to work:
Code:
<? |
For one thing, break it up with some whitespace so it's readable...
Try this: Code:
... |
>.< It made me go cross eyed :]
But quite usefull, if you want to have templates be more useful |
It doesn't work. :(
PHP code goes through (somewhat) unparsed. I can say: [code]<? if ($post[usergroupid] != 5) { $var = "..." } ?> And it would show up as... Code:
<? if (6 != 5) { |
I'm to stupid...
That what i get after insert the code. .... in functions... Quote:
|
Quote:
|
FILBURT I LOVE YOU!!!
*cliks install* (Yes i know i spelt click wrong i spelt it that way on purpose ;)) |
Im getting the page full of Parse error's as well. Running 2.2.7 if thats making any differance?
|
Quote:
|
Quote:
What do you mean by point 2? No php working for me. The require function just hangs on the IE browser. Can you fix that, fil? |
What is the exact code you're using?
|
PHP Code:
|
The template, not the PHP in gettemplate...
|
You're also not using my original hack, so I support it even less...
|
I'm not getting this to work either. Such is my code:
Quote:
Quote:
|
This hack doesn't work this way. All it does is blindly execute the code in the tags and a return statement will confuse the hell out of it.
Instead use: Code:
...<? $something = getenv("REQUEST_URI"); ?>$something... |
Still doesn't seem to work right. this code:
Quote:
Quote:
|
Make sure you're using my original hack and not the one you quoted.
|
Filburt. Doent know why,
but your origianl hack does not works in ant way. Our ou should write a manual, how to use it. I need to write freely php code in every template, can I do it? |
anyawy so that i can include files
cause when do it just displays on top no matter where i put the code |
GameZilla,
All you need is all I need. I don't care how - it must work as an ordinary php file!! |
All times are GMT. The time now is 11:50 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|