![]() |
Using External PHP Pages
Im trying to include an external php file in the VB template. I found this tutorial. I've added the following plugin with Global_Start as the Hook Location.
Plugins are Enabled in VB Options and the plugin itself is activated too. Code:
ob_start(); include('/home/.../bh_includes/head_common.php'); Nothing is showing up in my template though. |
You need to add this:
PHP Code:
|
Thanks
Where would i include that? |
<a href="https://vborg.vbsupport.ru/showthread.php?t=242454" target="_blank">[vBulletin 4] Simple way of including an external PHP file</a>
|
Quote:
|
So this is what i have right now:
Code:
ob_start(); include('/home/XXXX/public_html/bh_includes/head_common.php'); Its still not working |
Sorry, I probably confused you with my error. This should work:
PHP Code:
with this in the header template: {vb:raw includedheader} (the variable names needed to match in the ob_get_contents() and preRegister lines). |
I have a very similar question. My site is www.wavingthewheat.com
I am using a php script to count the number of rows in a table on the database. The script is loaded at www.wavingthewheat.com/chatuser.php I am trying to have the output of that file displayed in my navbar template. I have created a plugin with the following code PHP Code:
The php script works and displays the number of online users, however I can't get anything to display in the template using the plugin. |
Quote:
|
Quote:
That worked. Thanks a bunch. --------------- Added [DATE]1314819916[/DATE] at [TIME]1314819916[/TIME] --------------- I must the most idiot on this forums. I'm trying to include a second php file (for footer this time) and am having problems again. This time this is what im using: Code:
ob_start(); That doesnt work either. I changed the includedphp to includedfphp because using just the includedphp didnt work. I assumed it was because that variable was already being used elsewhere so i changed it (nothing happened though) |
Quote:
|
It is official. I am an idiot. I had a spelling error as well
|
Quote:
|
Quote:
I used the hook global_start. execution order 5. Does the PHP code need to be contained in <?php tags? Here is the code in my php file in case it matters. PHP Code:
|
You don't need the <?php in plugin code.
'parse_templates' is a different hook location, but 'global_start' will work so you're OK. I think you had another typo in the code you posted above (there's an extra space in 'includedphp ', which I now see is a typo in the "Rendering Templates..." article). Try this: PHP Code:
BTW, not to confuse things further, but you could also do something like this in the plugin: PHP Code:
and {vb:raw num_chatting} in the template, and you wouldn't need the external file. |
kh99 thanks a ton for your help. I decided to go with your last option and have the plugin execute the php.
I have a couple more questions though. 1.) What hook do I need to use so that this will display on the front page. It works on the forum, but not on the CMS. 2.) I would like to list who is online on the forum home. In that ajax_chat_online table each online user is stored in a row. I would like to display the column userName for all entries separated by a comma. Any thoughts? Again, thank you very much for all your help so far! |
Quote:
Quote:
PHP Code:
Obviously, if you're using the same plugin as you are for the count you could combine both so you're not doing two queries. |
Thanks! You had a typo but I caught it. Thanks for all of your help!!
--------------- Added [DATE]1314893620[/DATE] at [TIME]1314893620[/TIME] --------------- Man you have no idea how helpful you have been. With your help I have put together the following Mod Thread https://vborg.vbsupport.ru/showthread.php?p=2240829 to help everyone else who is in the same boat as me. --------------- Added [DATE]1314962655[/DATE] at [TIME]1314962655[/TIME] --------------- Well I have found one hiccup. With the second plugin. The one that displays the userNames. If no one is in the chat and the code returns a NULL result then it breaks the site. Gives me a cookie in header already sent error. Thoughts?? |
Bump
|
Sorry, I always seem to miss when posts get auto-merged.
Anyway, yeah, didn't think of that. You want something like this: PHP Code:
|
Perfect! Thanks!!
|
All times are GMT. The time now is 02:08 PM. |
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:
|