Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases

Reply
 
Thread Tools
Embed PHP in Templates Details »»
Embed PHP in Templates
Version: 1.00, by filburt1 filburt1 is offline
Developer Last Online: May 2007 Show Printable Version Email this Page

Version: 2.3.x Rating:
Released: 05-10-2003 Last Update: Never Installs: 16
 
No support by the author.

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...
<? $myvar = ($condition ? $truevalue : $falsevalue); ?>$myvar
...more template...
Just make sure that the variable to the left of the = and the variable right after the ?> match. Note that the entire <? and ?> tag itself will be stripped from the final 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.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #42  
Old 06-14-2003, 09:49 AM
DraX DraX is offline
 
Join Date: Aug 2002
Location: Bear, DE
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The problem with file inclusion is that this is completely contrary to the way in which vBulletin handles it's output buffering.

It doesn't generate line after line, it generates the entire page, and then sends that to the browser once it's compiled it.

For includes to work properly, anything (echos, output, etc.) would have to be stored as variables within the include, which are then echoed by the template itself.
Reply With Quote
  #43  
Old 06-14-2003, 10:28 AM
gmarik's Avatar
gmarik gmarik is offline
 
Join Date: May 2002
Location: Mocsow
Posts: 1,288
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

DraX - and what is the solution? Any code ideas?
Reply With Quote
  #44  
Old 06-19-2003, 07:29 AM
Rob - PROMISE Rob - PROMISE is offline
 
Join Date: Jun 2003
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello, sorry if this has been answered, I have read through and can't find anyhting relating to my problem.

I have installed the hack, I then dropped '<? ?>' (without the quotes) into the header of one of our templates. When I view the page it's not parsing the php, I can see the php tags in the source.

I then tried dropping an include in the same place but I then just get a blank page. I read that there are issues with using includes in the templates and I can live without using them although it would be very useful if I could.

Can you shead any light, let me know if you need any more details.

Thanks for your help people
Reply With Quote
  #45  
Old 06-19-2003, 08:43 AM
gmarik's Avatar
gmarik gmarik is offline
 
Join Date: May 2002
Location: Mocsow
Posts: 1,288
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You're not the only one.
I can't get php working in my 2.3 templates too.
Any solutions in v3? Anybody, Fil, xenon?!
Reply With Quote
  #46  
Old 06-26-2003, 10:54 AM
Veg Veg is offline
 
Join Date: May 2003
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can you retrive information from the database with this hack?
Reply With Quote
  #47  
Old 06-26-2003, 12:15 PM
gmarik's Avatar
gmarik gmarik is offline
 
Join Date: May 2002
Location: Mocsow
Posts: 1,288
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Theoreticaly it operates template DB. Theoreticaly.
Reply With Quote
  #48  
Old 07-07-2003, 11:45 AM
Importhookup Importhookup is offline
 
Join Date: Jun 2003
Location: Irvine, CA
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great hack!

I am so glad that I found this hack, but the problem is that I'm having trouble installing it. I did exactly what is written in the file, the simple replacement of the code but this is what I get on the top of myVBindex.php.

Warning: Failed opening 'randomride.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/importhookup/public_html/forums/admin/functions.php(1095) : eval()'d code on line 1

Parse error: parse error, unexpected T_INCLUDE in /home/importhookup/public_html/forums/admin/functions.php(1095) : eval()'d code on line 1

Parse error: parse error, unexpected T_INCLUDE in /home/importhookup/public_html/forums/admin/functions.php(1095) : eval()'d code on line 1

Can someone help me with this? Thanks!
Reply With Quote
  #49  
Old 08-05-2003, 04:26 AM
ChurchMedia's Avatar
ChurchMedia ChurchMedia is offline
 
Join Date: Dec 2002
Location: Las Cruces, NM
Posts: 473
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If I use include statements, it works but always puts the include file at the top of the page. Any way around this?

Thanks for the cool hack!
Reply With Quote
  #50  
Old 09-08-2003, 08:18 PM
Link14716's Avatar
Link14716 Link14716 is offline
 
Join Date: Jun 2002
Location: Georgia, USA
Posts: 2,519
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Not working... at least not in the postbit.

Code used:
PHP Code:
<?
if (!empty($post[field7])) {
$postfollower = "<br><br>";
$postfollower = $postfollower."".bbcodeparse2($post[field7],0,1,1,1);
}
if (!empty($post[field5])) {
$posttextcolor = "color='".$post[field5]."'";
}
if (!empty($post[field6])) {
$postfontface = "face='".$post[field6]."'";
}
if (!empty($postfontface) || !empty($posttextcolor)) {
?>
<font $postfontface $posttextcolor>
<? } ?>
$post[message] 
<? if (!empty($postfontface) || !empty($posttextcolor)) { ?>
</font>
<? } ?>
$postfollower
View Source gives me this, of course on the page the code didn't work:
Code:
<?
if (!empty([b]Official[/b] Code +++++)) {
 = "<br><br>";
 = ."".bbcodeparse2([b]Official[/b] Code +++++,0,1,1,1);
}
if (!empty(blue)) {
 = "color='".blue."'";
}
if (!empty(WingDings)) {
 = "face='".WingDings."'";
}
if (!empty() || !empty()) {
?>
<font  >
<? } ?>
I've nailed the store, arcade, increased the arcade's number of games to 41, installed quick reply, and installed zajako's RPG hack. I'm done for tonight. 
<? if (!empty() || !empty()) { ?>
</font>
<? } ?>
Reply With Quote
  #51  
Old 09-09-2003, 03:06 PM
gmarik's Avatar
gmarik gmarik is offline
 
Join Date: May 2002
Location: Mocsow
Posts: 1,288
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is it working in v3?
Reply With Quote
Reply

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

Forum Jump


All times are GMT. The time now is 02:29 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04653 seconds
  • Memory Usage 2,303KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete