vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Embed PHP in Templates (https://vborg.vbsupport.ru/showthread.php?t=52775)

filburt1 05-10-2003 10:00 PM

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...
<? $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.

filburt1 05-10-2003 11:59 PM

Admin CP:

filburt1 05-11-2003 12:00 AM

The result:

Koutaru 05-11-2003 12:49 AM

I'm definately going to use this when I get back :) Thanks for the hack filburt!

Link14716 05-11-2003 02:04 AM

Wow, this leaves all the template conditional hacks in the dust. I might even install this one!

Great job, filburt!

N9ne 05-11-2003 08:29 AM

Very nice filby! Is this efficient?

Trigunflame 05-11-2003 08:34 AM

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...

Dean C 05-11-2003 12:41 PM

What are the limitations on the use of PHP ?

- miSt

N9ne 05-11-2003 01:39 PM

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.

Danielo 05-11-2003 03:31 PM

Thank you very much... i try to use this script


All times are GMT. The time now is 07:42 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.01211 seconds
  • Memory Usage 1,725KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete