View Full Version : Include File in Template
TheInsaneManiac
07-29-2008, 07:14 AM
I have a piece of code that is only suppose to run when the $denyadminip is put into a template. For some reason it is running everywhere on the forums. I know I set it to global, but it should only run when I put $denyadminip. Anyway here is the code:
<hookname>global_start</hookname>
<phpcode><![CDATA[ob_start();
include('allowip.php');
$denyadminip = ob_get_contents();
ob_end_clean();]]></phpcode>
Opserty
07-29-2008, 07:50 AM
Plugins are always run depending on their hook location, changing what is in the template has no effect on a plugin. Change the hook location if you want to change when/where a plugin is execute.
$denyadminip is just the output and nothing else.
TheInsaneManiac
07-29-2008, 08:44 PM
Plugins are always run depending on their hook location, changing what is in the template has no effect on a plugin. Change the hook location if you want to change when/where a plugin is execute.
$denyadminip is just the output and nothing else.
Is there a way to include a php file and then making it execute by putting $denyadminip in it?
MoT3rror
07-30-2008, 03:28 AM
ob_start();
include('allowip.php');
$denyadminip = ob_get_contents();
ob_end_clean();
eval('$denyadminip = "' . $denyadminip . '"');
TheInsaneManiac
07-30-2008, 03:30 AM
Thanks!
--------------- Added 1217393167 at 1217393167 ---------------
Actually it is still executing the contents of allowip.php on all pages. So any other solutions?
--------------- Added 1217393479 at 1217393479 ---------------
Actually that code causes my profiles to not be able to be viewed.
Opserty
07-30-2008, 08:52 PM
Change the hook location if you want to change when/where a plugin is executed.
Else you need to think up some kind of condition to enclose the include.
TheInsaneManiac
07-31-2008, 01:58 AM
Else you need to think up some kind of condition to enclose the include.
What would be the condition to use if I wanted to use it on allowip.php?
RLShare
07-31-2008, 03:14 AM
The way you have it set at global its going to execute everywhere. You could change the hook location to only where you want it to execute or You could check for certain $variables that are only defined in certain sections of the site before you execute it, such as $threadinfo when viewing threads...etc. Or you could check the THIS_SCRIPT constant against what the constant is defined as in the file you want it executed. Theres a million or more ways to accomplish it. It would be easier to help you if you gave information about where your trying to get it to execute. There is no way to just say hey if I put this variable in this template thats when you need to execute the code to fill the variable.
TheInsaneManiac
08-02-2008, 03:19 AM
I am trying to execute it in a file I made. It does have a THIS_SCRIPT, so how would I set it up to use this?
Dismounted
08-02-2008, 04:36 AM
If you are trying to execute that code in a custom file - why not put it into the file in the first place?
TheInsaneManiac
08-03-2008, 05:01 AM
Because you can't include php code in a template can you?
Dismounted
08-03-2008, 05:10 AM
You said file - which indicates PHP files - you can run PHP in PHP files, can't you?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.