The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
PHP API code in template, php file, or somewhere else?
I have the following PHP code:
Code:
<? require_once('./api/class.api.php'); require_once('./api/class.charselect.php'); $api = new Api(); $api->debug(false); $api->cache(false); $api->setCredentials($apiuser,$apipass); $uchars = $api->getCharacters(); $chars = CharSelect::getCharacters($uchars); $apichar = $chars[0]['charname']; $api->setCredentials($apiuser,$apipass,$apichar); ?> |
#2
|
||||
|
||||
You will need to create a plugin at the appropriate location as you cannot run PHP code in templates directly.
|
#3
|
|||
|
|||
This will need to be called many times with different settings. Do I need a seperate plugin for each call ($359api_chars, $359api_tree, etc) or can the plugin be used as an array? I followed the instructions from https://vborg.vbsupport.ru/showthrea...ghlight=plugin, but when I put $359eveit[1][charname] in the display template, it actually shows the variable name, rather than nothing. Considering it should be a blank variable, it should display nothing, right?
|
#4
|
|||
|
|||
PHP variable names cannot begin with a number.
|
#5
|
|||
|
|||
Thank you, having all these problems and never thought of that
Alright, I've changed everything around so it is now $eveit359. Plugin output is now getting to the template, as long as it's plain HTML. When I try to make $eveit359 into an array (store a value into $eveit359[1], and put that in the template, I get output like "p[charname]". I am completely lost trying to figure out what the heck the template/plugin tutorials are saying with variable renaming or whatever it is they're talking about. I need to have several arrays of data accessible to the template, preferably in one big array $eveit359[1][charname], $eveit359[1][charid], $eveit359[1][tree][current], $eveit359[1][tree][time], etc. |
#6
|
|||
|
|||
I don't know might be something to do with your script. Arrays start from 0 not 1. I don't know why you are storing it in arrays you can store it as a variable normally. If it makes it easier to use arrays then use arrays. If you have multidimension arrays consider surrounding it in brackets. Like in your template have:
PHP Code:
PHP Code:
|
#7
|
|||
|
|||
My current plugin template content:
PHP Code:
I tried changing the plugin template to a simple PHP Code:
PHP Code:
Not sure if what you meant was to use another variable in the plugin and display templates, but I tried PHP Code:
Could the Api functions be causing a problem? The plain text script output starts with "debug(false); $api359->cache(true);" as if that first "->" is a problem. --------------- Added [DATE]1200517434[/DATE] at [TIME]1200517434[/TIME] --------------- I just tried PHP Code:
HTML Code:
<?php
echo \"<font color=white>Hello</font>\";
?>
If I change the double quotes to single quotes, output is blank. |
#8
|
||||
|
||||
You don't need to have <?php and ?> in plugins, as the code is evaluated (using eval()).
|
#9
|
|||
|
|||
New plugin template:
PHP Code:
Code:
require_once('./eveitapi/class.api.php'); require_once('./eveitapi/class.charselect.php'); = new Api(); (false); // enable debugging (false); // do not use a cache-file, if one exists (1188020,RDQiA46jtGtzMUEFVtgbtJ2CfhTCIPGkD0JeUz22NomPeQWCx552fwe0gwkSi4bh); = (); = CharSelect::getCharacters(); = [charname]; = "Hello"; echo "Hello"; The above is using the "eval" plugin and "array_merge" cache plugin. When I use the method from this post I get the following output. Still doesn't parse it, but at least this way it's not evaluating the variables. Code:
require_once('./eveitapi/class.api.php'); require_once('./eveitapi/class.charselect.php'); $api359 = new Api(); $api359->debug(false); // enable debugging $api359->cache(false); // do not use a cache-file, if one exists $api359->setCredentials(" . $GLOBALS['vbulletin']->userinfo['field6'] . "," . $GLOBALS['vbulletin']->userinfo['field7'] . "); $uchars359 = $api359->getCharacters(); $chars359 = CharSelect::getCharacters($uchars359); $eveitapi = $chars359[0][charname]; $charblahtest = \"Hello\"; echo \"Hello\"; |
#10
|
|||
|
|||
What editor are you using? Looks like all linebreaks are removed.
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|