![]() |
PHP API code in template, php file, or somewhere else?
I have the following PHP code:
Code:
<? |
You will need to create a plugin at the appropriate location as you cannot run PHP code in templates directly.
|
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?
|
PHP variable names cannot begin with a number.
|
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. |
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:
|
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 If I change the double quotes to single quotes, output is blank. |
You don't need to have <?php and ?> in plugins, as the code is evaluated (using eval()).
|
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\"; |
What editor are you using? Looks like all linebreaks are removed.
|
All times are GMT. The time now is 04:47 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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|