The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
[vBulletin 4] Simple way of including an external PHP file
There are other articles out there on variables, templates, etc on vBulletin 4. This is a simple example of including an external PHP files like you used to be able to do here: http://www.vbulletin.com/forum/showt...P-or-HTML-File Thanks to this Blog post by David IB http://www.vbulletin.com/forum/entry...s-to-templates and this article by cellarius https://vborg.vbsupport.ru/showthread.php?t=228078 I have figured out it's only a simple extra step. Step 1: Create a new plugin
Step 2: You will have to figure out these two entries for yourself: LOCATION OF EXTERNAL FILE & Hook Location To give you an example of what you should use is that if you want to display your external PHP file on your Forum's Home. Then replace these two with these values: Hook Location with forumhome_start TEMPLATE YOU ARE USING with FORUMHOME Keep in mind that global_start will still be acceptable, but it's extra loading time where it's not needed. Therefore choosing the optimum hook location is better for your performance overall. Step 3: Visit the Style Manager -> TEMPLATE YOU ARE USING and place the variable in your style where you want it. You will have to use the new format. Code:
{vb:raw php_include} Notes, If you want to: Include this PHP file in multiple templates then preRegister it for the multiple templates: Code:
vB_Template::preRegister('TEMPLATE YOU ARE USING',array('php_include' => $php_include)); vB_Template::preRegister('TEMPLATE YOU ARE USING 2',array('php_include' => $php_include)); I'm still learning as I go with vb4, but if I learn some more notes to add... I'll drop by here. I hope that helps some one out there! |
#102
|
|||
|
|||
So, i have to make a plugin to register those two variables or what? I am little bit missing right now.
|
#103
|
|||
|
|||
Well, right, you'd have to do that in php, which means a plugin or modifying a script. But the issue seems to be where those variables are coming from. The code you posted looks like you're trying to capture the entire output of vbtrade.php into each of those variables, which won't work. But I'm not sure what to tell you to do instead of that.
Edit: I'm thinking now that you don't need this "include external files" thing at all. If you're trying to modify vbtrade.php to work with vb4, then you probably want to edit that script and change the way the templates are rendered. |
#104
|
|||
|
|||
Quote:
Code:
$templater = vB_Template::create('forumdisplay_sortarrow'); $templater->register_page_templates(); $templater = vB_Template::create('vbtrade_main'); $templater->register_page_templates(); $templater->register('pagetitle', $pagetitle); $templater->register('alt', $alt); $templater->register('stocktable', $stocktable); $templater->register('preview', $preview); print_output($templater->render()); |
#105
|
|||
|
|||
OK, that's already written for vb4, so it doesn't need to be changed. Sorry, I probably just misunderstood what you're trying to do.
You said you're trying to modify a vb3 plugin for vb4, so you were right, if it involved using variables in a template, you might have to register them. Is your vb3 plugin code calling fetch_template() then eval()? Edit: OK, I just noticed that the code you posted above from vbtrade.php is rendering the vbtrade_main template and already registers $stocktable and $preview, so I'm lost. What does the plugin do? |
#106
|
|||
|
|||
Quote:
|
#107
|
|||
|
|||
is there anyway to get this to work in an Iframe
i try HTML Code:
<iframe src="{vb:raw perm}" width="530" height="600" frameBorder="0" class="leftColumn"></iframe> this is the plugin i use PHP Code:
|
#108
|
||||
|
||||
If what you want is the output of $perm in the iframe simply make the iframe src="url/perm/perm.php"
|
#109
|
|||
|
|||
Quote:
HTML Code:
<iframe src="{vb:raw perm}" width="530" height="600" frameBorder="0" class="leftColumn"></iframe> <iframe src="{vb:raw temp}" width="530" height="600" frameBorder="0" class="leftColumn"></iframe> |
#110
|
||||
|
||||
From the code you posted above, $perm = ob_get_contents();
That means $perm is the contents of the output buffer or the output (presumably) of the perm.php page. NOT a URL. But the iframe SRC is looking for a URL ONLY. You can't put iframe content in the src= attribute. Actually, it appears HTML5 does allow you to specify the code in the iframe but it uses the srcdoc attribute - http://www.w3schools.com/tags/tag_iframe.asp |
#111
|
|||
|
|||
Hi there,
For some reason I can include the PHP file, but my header and navbar goes funny. I know it's the plugin in as when I turn the plugin off, the header and navbar works fine. The header and navbar works fine, but it changes to: My navbar/headers are #vbtab_form# $tab_mdu1_245 and #vbflink_pms# #vbmenu_community# and I'm missing some of my footer menu links. Very odd that it works but my css stuffs up. Thank you for your help. Cheers |
Thread Tools | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|