The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
How to include PHP in a template via Plugins
Hi,
Currently, I have this. PHP Code:
How can I - instead of using table.php, put the PHP code that is already IN table.php in the actual plugin and still use $includedphp in the template? If someone gets the link to table.php, they will be able to see info I don't want them to see -- the table.php is literally just PHP/MySQL table code, I have it calling it to a template to look nicer and in the template, I have it so only Staff usergroup ids can see it, but I can't make it that way for the table.php, since it isn't part of vBulletin. Hope this was clear. Just trying to put the PHP code inside of the Plugin instead of using include('table.php') |
#2
|
||||
|
||||
Have you tried just copying it into the plugin?
|
Благодарность от: | ||
CoffeeLovesYou |
#3
|
|||
|
|||
Yes but I'm not sure where to put it.
For example, would it be.. PHP Code:
PHP Code:
|
#4
|
||||
|
||||
All you would need is:
PHP Code:
|
#5
|
|||
|
|||
how would I attach that to my template, then?
|
#6
|
|||
|
|||
I think it's the second example you posted above, since the code in table.php probably outputs html and you'd still need to capture it, unless you rewrite the code so that the output is saved in a string.
|
#7
|
|||
|
|||
I've tried the second example, but I get thrown a compile_template error all over my forum.
I have tried putting the actual PHP code in the template, doesn't work. I have tried including the php file in the plugin then calling it in the template with $includedphp but if someone got the link to the php file in the plugin, they could see the form that only staff are supposed to see. I don't want that. |
#8
|
|||
|
|||
OK, if this works:
Code:
ob_start(); include('table.php'); $includedphp = ob_get_contents(); ob_end_clean(); Then you should be able to do this: Code:
ob_start(); // code from table.php here $includedphp = ob_get_contents(); ob_end_clean(); but you have to remove <?php from the begininng, and ?> from the end (if it's there). If what you're saying is that you're worried about someone going directly to table.php, then you could put a check at the beginning of table.php (after the <?php) like: Code:
if (!defined('THIS_SCRIPT')) die("permission denied."); |
#9
|
|||
|
|||
I get this when I try to put the code instead of including the PHP file
Fatal error: Call to undefined function compile_template() in my root forums/global.php(607) : eval()'d code on line 651 The plugin hook is global_start |
#10
|
|||
|
|||
Hmm...the error looks like the code in table.php is trying to use the function compile_template() and isn't finding it, but I don't see why moving the code from table.php to the plugin would do that. It seems like you should be getting the same error if you include the file like you show in the first post. Also, I'm curious what the code is doing where it would need to call compile_template() - that seems a little strange for a plugin using global_start. That's really an adminCP function (unless it's trying to call a non-vbulletin function of the same name).
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|