vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   how to execute php code in the vb template (https://vborg.vbsupport.ru/showthread.php?t=211334)

larry_wic 04-16-2009 01:48 AM

how to execute php code in the vb template
 
I've seen the link to the functions you can run, using the < if condition> tags, etc.

i saw somethign about a plugin (i was confused on that)

I don't see / understand how you do this?
I run this little code on all my pages, as i want to track how they got to my pages
[[ yes, i use other log analyzers, other track analytic software, but i have a specific reason why i need this too]]

so I do get how i could use the if condidtion tags to do this?
i can't call the script / include it -- as i loose the refer data.
i'm pretty sure i need to run it ASAP as the visitor lands on the page.

Code:

session_start();
 if (empty($_SESSION['vREFERER'])) {
$vREFERER = $_SERVER['HTTP_REFERER'];
session_register('vREFERER'); }

so anyone know how, where i could run this php code in the vb template?

THANKS

Dismounted 04-16-2009 02:50 AM

As you've found out, raw PHP cannot be run inside templates. PHP must be run in plugins.

The Plugin Manager

TigerC10 04-16-2009 02:54 AM

You can use PHP, but the template manager restricts what PHP you can use to these functions:
  • in_array
  • is_array
  • is_numeric
  • isset
  • empty
  • defined
  • array
  • can_moderate
  • can_moderate_calendar
  • exec_switch_bg
  • is_browser
  • is_member_of

http://www.vbulletin.com/docs/html/f...n_conditionals



If you need something other than that, you'll have to do what Dismounted said and use a plugin.

Dismounted 04-16-2009 03:06 AM

That PHP is only allowed in conditionals, and no where else.

larry_wic 04-16-2009 03:55 AM

so i can't do this:

Code:

<if condition="session_start()">
 if (empty($_SESSION['vREFERER'])) {
$vREFERER = $_SERVER['HTTP_REFERER'];
session_register('vREFERER'); }
</if>

you can tell, i don't get it :(

Dismounted 04-16-2009 04:35 AM

No, you can't do that. You must add a plugin to do what you want - I have already posted a link to the manual. Read it.

TigerC10 04-16-2009 05:02 AM

You can do this...

Code:

<if condition="empty($_SESSION['vREFERER'])">
Referrer: $_SERVER['HTTP_REFERER']
</if>

You can check if something is empty, but you can't assign new variables and you can't register anything...

Dismounted 04-16-2009 05:34 AM

That wouldn't work - the quotes would fail. Also, I don't know if you can access superglobals in templates directly (they may be cleared, or it might be at some other point, I don't remember).

vbplusme 04-16-2009 06:00 AM

You should take a look at the plugin section of the vBulletin manual to check out plugins and how they work. The architecture is a little strange at first but once you figure out the order, you can do a lot with it, including what you are trying to do I think.

http://www.vbulletin.com/docs/html/main/plugin_system


All times are GMT. The time now is 12:05 AM.

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.01018 seconds
  • Memory Usage 1,726KB
  • 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
  • (3)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete