The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Failing to include PHP files into a hook
I?m trying to set up the forums at my site and I need to include a few php files into the header, at the top of the vBulletin site, right after the <BODY> tag.
I?ve read https://vborg.vbsupport.ru/showthrea...ht=include+php over and over, but it won?t register any variables. Here is what I did: I created a Plugin: //#### Begin Plugin #### ob_start(); // Included file is located one directory from the Forums, and in another directory include("../AnotherDirectory/IncludeThisFile.php"); $includephp = ob_get_contents(); ob_end_clean(); // The 'header' template is where I want to output the files vB_Template:reRegister('header', array('includedphp ' => $includedphp)); //#### End Plugin #### I used a variety of hook locations. I?m positive it is correct. For this, I used 'forumhome_start' and 'global_bootstrap_start', and I got the same results. Then I went to the 'header' template, and at the top I added: {vb:raw includephp} However, when I run the forums, the additional PHP content doesn't appear. So, I altered the Plugin: //#### Begin Plugin #### ob_start(); // Included file is invalid include("../AnotherDirectory/InvalidFileDoesNotExist.php"); $includephp = ob_get_contents(); ob_end_clean(); vB_Template:reRegister('header', array('includedphp ' => $includedphp)); //#### End Plugin #### When I run the forums again, I get a PHP error message, saying file not found. Therefore, I concluded that the first plugin code is fine. So, I altered the Plugin to something simple: //#### Begin Plugin #### $includephp = ?<p>Hello</p>?; vB_Template:reRegister('header', array('includedphp ' => $includedphp)); //#### End Plugin #### When I run the forums again, additional content doesn't output. I can?t find 'Hello' on the page. So, now I edited the 'header' template, and entered at the top: <p>Hello</p> When I run the forums again, '<p>Hello</p>' is outputted on the top of the page before anything else is generated. Therefore, I concluded that I need to register the variable in the hook. Where do I register variables? Am I even doing it right? I have been spending several days trying to get this to work, and nothing. And yes, I explicidly followed the instructions on the forums, and nothing. Samwise Galenorn |
#2
|
||||
|
||||
$includephp = “<p>Hello</p>”;
vB_Template:reRegister('header', array('includedphp ' => $includedphp)); See the variable names in bold. One of them has an additional d - includedphp |
#3
|
|||
|
|||
Thanks. I knew it had to be something dumb by me.
However... Here is the plugin now: //#### Begin Plugin #### ob_start(); // Included file is located one directory from the Forums, and in another directory include("../AnotherDirectory/IncludeThisFile.php"); $includephp = ob_get_contents(); ob_end_clean(); // The 'header' template is where I want to output the files vB_Template:reRegister('header', array('includephp ' => $includephp)); //#### End Plugin #### And I tried: //#### Begin Plugin #### $includephp = <p>Hello</p>; vB_Template:reRegister('header', array('includephp ' => $includephp)); //#### End Plugin #### And I still get no output either way. Am I supposed to register the variable in the hook itself, or do I alter the actual code file? Samwise Galenorn |
#4
|
||||
|
||||
This works perfectly fine for me at global_bootstrap_complete:
PHP Code:
|
#5
|
|||
|
|||
Before, I did:
//#### Begin Plugin #### $includephp = '<p>Hello</p>'; vB_Template:reRegister('header', array('includephp ' => $includephp)); //#### End Plugin #### I put into the array variable 'include ' (with a space). I need to put into the array variable 'include' (with no space). Corrected: //#### Begin Plugin #### $includephp = '<p>Hello</p>'; vB_Template:reRegister('header', array('includephp' => $includephp)); //#### End Plugin #### (Glorious results of copy/paste of someone's code... *groan*...) And now it works Thank you |
#6
|
||||
|
||||
I'm glad you got it working.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|