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
  #52  
Old 09-27-2003, 07:32 PM
Tae-Hwan Tae-Hwan is offline
 
Join Date: May 2002
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

filburt, in your opinion does this render logician's conditionals hack obsolete? i'm fluent in php. i liked logician's conditionals a lot except that it was kinda slow..
Reply With Quote
  #53  
Old 09-29-2003, 01:12 AM
drives fast's Avatar
drives fast drives fast is offline
 
Join Date: Nov 2001
Posts: 263
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have tried many combinations and haven't figured out this one yet

if someone would be so kind

this is what I had figured out in the vb3 conditionals:
PHP Code:
<if condition="$post[usergroupid]==11"><font color="#ffcc00" face="verdana, arial, helvetica" size="1"><b>Site Supporter</b></font> <img src="/forum/eimages/supporter.gif" width="11" height="11" border="0" /></if> 
how can that be modified to work within the <? ?> in the earlier vbulletin version that I have installed this hack in?

I have tried several things but only get parse errors displayed above the header

stuff like:
PHP Code:
<?
if (condition = $post[usergroupid]==11) {
$var = "<font color=\"#ffcc00\" face=\"verdana, arial, helvetica\" size=\"1\"><b>Site Supporter</b></font> <img src=\"/forum/eimages/supporter.gif\" width=\"11\" height=\"11\" border=\"0\" />"
}
?>
and:
PHP Code:
<?
if ($post[usergroupid] != 11) {
$var = "<smallfontcolor='#ffcc00'><b>Site Supporter</b></smallfont> <img src='/forum/eimages/supporter.gif' width='11' height='11' border='0' />"
}
?>
I know it is just because I don't know the language to use

thanks a bunch for any help
Reply With Quote
  #54  
Old 10-02-2003, 04:18 AM
drives fast's Avatar
drives fast drives fast is offline
 
Join Date: Nov 2001
Posts: 263
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

once again...I couldn't get bit by a dog even with a steak hanging around my neck
Reply With Quote
  #55  
Old 10-17-2003, 08:10 PM
Tae-Hwan Tae-Hwan is offline
 
Join Date: May 2002
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by drives fast
once again...I couldn't get bit by a dog even with a steak hanging around my neck
hehe, i never heard that one before...

well, i don't have any experience in vbulletin 3, but if i'm understanding the code correctly, it should look something like this in php:

PHP Code:
<? 
if ($post[usergroupid]==11) { 
echo "<font color=\"#ffcc00\" face=\"verdana, arial, helvetica\" size=\"1\"><b>Site Supporter</b></font><img src=\"/forum/eimages/supporter.gif\" width=\"11\" height=\"11\" border=\"0\">";

?>
Reply With Quote
  #56  
Old 10-18-2003, 01:20 AM
drives fast's Avatar
drives fast drives fast is offline
 
Join Date: Nov 2001
Posts: 263
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thank you...I will give that a try.

it looks like it will work though....I forgot about the "echo"
Reply With Quote
  #57  
Old 10-19-2003, 03:06 PM
gmarik's Avatar
gmarik gmarik is offline
 
Join Date: May 2002
Location: Mocsow
Posts: 1,288
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

We all forget some times about the quotes or the echo ...
Reply With Quote
  #58  
Old 11-13-2003, 08:19 PM
stephenv stephenv is offline
 
Join Date: Nov 2003
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I read through some of the other messages AFTER modifying/fixing the original script, I would have added the <?php ?> <php> </php> stuff but I can't be arsed. On a deadline for other stuff.

That said, attached is an updated version that uses output buffering (in case you want to echo text) and also fixes the str_replace that didn't do squat



Mail me at stephen AT natnet DOT com if you want to say thanks or have questions, today was my first day on the board and I probably won't be back (fixed for a client who wanted to use phpAdsNew).
Reply With Quote
  #59  
Old 12-08-2003, 09:04 AM
NuclioN's Avatar
NuclioN NuclioN is offline
 
Join Date: Aug 2002
Posts: 955
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Very usefull! I hope this will possible in vb3 soon.
Reply With Quote
  #60  
Old 01-14-2004, 01:35 AM
spittingangels spittingangels is offline
 
Join Date: Mar 2002
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by stephenv
I read through some of the other messages AFTER modifying/fixing the original script, I would have added the <?php ?> <php> </php> stuff but I can't be arsed. On a deadline for other stuff.

That said, attached is an updated version that uses output buffering (in case you want to echo text) and also fixes the str_replace that didn't do squat

Mail me at stephen AT natnet DOT com if you want to say thanks or have questions, today was my first day on the board and I probably won't be back (fixed for a client who wanted to use phpAdsNew).

With these modifications, the hack works like a charm for what I needed it to do, which was to pull a php file into the header template via include(). the original hack would pull the file into the page but only at the top of the page and not where it was supposed to display.

For everyone else that had a similar problem, try this version. My thanks to both authors that worked on this.
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 12:40 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
  • Page Generation 0.07447 seconds
  • Memory Usage 2,311KB
  • Queries Executed 26 (?)
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
  • (1)bbcode_code
  • (4)bbcode_php
  • (2)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
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)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