Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 31 Aug 2011, 16:58
nima6's Avatar
nima6 nima6 is offline
 
Join Date: Jan 2007
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.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And then I'm calling for {vb:raw includedheader} in the FORUMDISPLAY file.

Nothing is showing up in my template though.
Reply With Quote
  #2  
Old 31 Aug 2011, 17:07
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
You need to add this:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Last edited by kh99; 31 Aug 2011 at 17:50. Reason: fixed error
Reply With Quote
  #3  
Old 31 Aug 2011, 17:31
nima6's Avatar
nima6 nima6 is offline
 
Join Date: Jan 2007
Thanks

Where would i include that?
Reply With Quote
  #4  
Old 31 Aug 2011, 17:37
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
[vBulletin 4] Simple way of including an external PHP file
__________________
Former vBulletin.org Staff Member

Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #5  
Old 31 Aug 2011, 17:51
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Originally Posted by nima6 View Post
Thanks

Where would i include that?
At the end, as in the article Lynne linked to. And sorry, BTW, what I posted actually had an error in it.
Reply With Quote
  #6  
Old 31 Aug 2011, 18:25
nima6's Avatar
nima6 nima6 is offline
 
Join Date: Jan 2007
So this is what i have right now:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And using {vb:raw includedheader} in the "header" file in the template.

Its still not working
Reply With Quote
  #7  
Old 31 Aug 2011, 18:46
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Sorry, I probably confused you with my error. This should work:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


with this in the header template: {vb:raw includedheader}

(the variable names needed to match in the ob_get_contents() and preRegister lines).
Reply With Quote
  #8  
Old 31 Aug 2011, 19:40
ICThawk ICThawk is offline
 
Join Date: Feb 2011
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


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

In my navbar template I have {vb:raw includedphp} as part of the Chat link.

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.
Reply With Quote
  #9  
Old 31 Aug 2011, 19:50
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Originally Posted by ICThawk View Post
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.
It looks like you've misspelled 'navbar' in your preregister call.
Reply With Quote
  #10  
Old 31 Aug 2011, 20:14
nima6's Avatar
nima6 nima6 is offline
 
Join Date: Jan 2007
Originally Posted by kh99 View Post
Sorry, I probably confused you with my error. This should work:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


with this in the header template: {vb:raw includedheader}

(the variable names needed to match in the ob_get_contents() and preRegister lines).


That worked. Thanks a bunch.

--------------- Added 31 Aug 2011 at 20:45 ---------------

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:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

and {vb:raw includedfooter}

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)
Reply With Quote
  #11  
Old 31 Aug 2011, 20:50
ICThawk ICThawk is offline
 
Join Date: Feb 2011
Originally Posted by kh99 View Post
It looks like you've misspelled 'navbar' in your preregister call.
Good catch. Sadly with that fixed it still doesn't work. Ideas?
Reply With Quote
  #12  
Old 31 Aug 2011, 21:14
nima6's Avatar
nima6 nima6 is offline
 
Join Date: Jan 2007
It is official. I am an idiot. I had a spelling error as well
Reply With Quote
  #13  
Old 31 Aug 2011, 21:41
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Originally Posted by ICThawk View Post
Good catch. Sadly with that fixed it still doesn't work. Ideas?
Which hook are you using? Try using parse_templates if you aren't already.
Reply With Quote
  #14  
Old 01 Sep 2011, 02:16
ICThawk ICThawk is offline
 
Join Date: Feb 2011
Originally Posted by kh99 View Post
Which hook are you using? Try using parse_templates if you aren't already.
I don't know what parse templates are.

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.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #15  
Old 01 Sep 2011, 06:39
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.




BTW, not to confuse things further, but you could also do something like this in the plugin:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


and {vb:raw num_chatting} in the template, and you wouldn't need the external file.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 18:17.

Layout Options | Width: Wide Color: