Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases
FAQ Community Calendar Today's Posts Search

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
  #22  
Old 05-13-2003, 01:18 PM
filburt1 filburt1 is offline
 
Join Date: Feb 2002
Location: Maryland, US
Posts: 6,144
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

For one thing, break it up with some whitespace so it's readable...

Try this:
Code:
...
<?
if (empty($page)) $page = "default";
include("$page.html");
?>
Also include and require may cause unpredictable results; you'll probably need to play with the output buffering settings and that'll destroy gzip.
Reply With Quote
  #23  
Old 05-14-2003, 04:12 AM
zajako's Avatar
zajako zajako is offline
 
Join Date: Jan 2002
Location: a place not to far away
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

>.< It made me go cross eyed :]
But quite usefull, if you want to have templates be more useful
Reply With Quote
  #24  
Old 05-14-2003, 09:09 PM
cirisme cirisme is offline
 
Join Date: Jan 2003
Posts: 136
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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) {
$var = "..."
}
With the 6 being the correct usergroup id. :ermm:
Reply With Quote
  #25  
Old 05-17-2003, 01:08 PM
Wildthinks's Avatar
Wildthinks Wildthinks is offline
 
Join Date: Apr 2002
Location: .:BeRLiN:.
Posts: 96
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm to stupid...

That what i get after insert the code. .... in functions...
Quote:
Parse error: parse error in /homepages/22/d65974721/htdocs/vb/index.php(463) : eval()'d code on line 1

Parse error: parse error in /homepages/22/d65974721/htdocs/vb/index.php(550) : eval()'d code on line 1

Parse error: parse error in /homepages/22/d65974721/htdocs/vb/index.php(571) : eval()'d code on line 1

Parse error: parse error in /homepages/22/d65974721/htdocs/vb/index.php(571) : eval()'d code on line 1

Parse error: parse error in /homepages/22/d65974721/htdocs/vb/index.php(571) : eval()'d code on line 1

Parse error: parse error in /homepages/22/d65974721/htdocs/vb/index.php(571) : eval()'d code on line 1

Parse error: parse error in /homepages/22/d65974721/htdocs/vb/index.php(571) : eval()'d code on line 1
Any hints for me?
Reply With Quote
  #26  
Old 05-17-2003, 01:31 PM
filburt1 filburt1 is offline
 
Join Date: Feb 2002
Location: Maryland, US
Posts: 6,144
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
05-14-03 at 06:09 PM cirisme said this in Post #23
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) {
$var = "..."
}
With the 6 being the correct usergroup id. :ermm:
Are you sure you installed it correctly? In what template are you using that code?
Reply With Quote
  #27  
Old 05-18-2003, 03:47 AM
Katana Myronson Katana Myronson is offline
 
Join Date: Oct 2002
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

FILBURT I LOVE YOU!!!

*cliks install*

(Yes i know i spelt click wrong i spelt it that way on purpose )
Reply With Quote
  #28  
Old 05-19-2003, 02:18 PM
mossyuk mossyuk is offline
 
Join Date: Jul 2002
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Im getting the page full of Parse error's as well. Running 2.2.7 if thats making any differance?
Reply With Quote
  #29  
Old 05-19-2003, 04:37 PM
cirisme cirisme is offline
 
Join Date: Jan 2003
Posts: 136
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
05-17-03 at 08:31 AM filburt1 said this in Post #25
Are you sure you installed it correctly? In what template are you using that code?
Yes, I triple checked it and it doesn't work. That was in postbit, but I've tried it in the header as well.
Reply With Quote
  #30  
Old 05-21-2003, 02:00 PM
gmarik's Avatar
gmarik gmarik is offline
 
Join Date: May 2002
Location: Mocsow
Posts: 1,288
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
05-12-03 at 02:04 AM filburt1 said this in Post #15
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.

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?
Reply With Quote
  #31  
Old 05-21-2003, 03:15 PM
filburt1 filburt1 is offline
 
Join Date: Feb 2002
Location: Maryland, US
Posts: 6,144
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What is the exact code you're using?
Reply With Quote
Reply


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 01:45 AM.


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.08214 seconds
  • Memory Usage 2,309KB
  • Queries Executed 27 (?)
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
  • (4)bbcode_code
  • (4)bbcode_quote
  • (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
  • (4)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_postinfo_query
  • fetch_postinfo
  • 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