View Full Version : How to get this php code into a plugin?
Gladius2007
07-14-2008, 10:44 PM
Pretty simple question, but I can't figure it out... the original code is
<?php require_once('/home/path/file.php'); ?>
<?php output_NewestThreads(10,"36"); ?>
I'm using it on a regular php page to display latest threads (properly, not how most hacks do it). I can't seem to get it to work in a plugin though, so that I could use it on the board pages too... I've tried several variants that I could think of, but nothing works (getting blank pages). Can anyone point me in the right direction? Thanks.
Opserty
07-14-2008, 10:55 PM
<a href="http://www.vbulletin.com/docs/html/main/templates_externalfiles" target="_blank">Including External Files</a>
Gladius2007
07-15-2008, 12:24 AM
I've seen that, yes, but if you look at the code you'll see that those instructions aren't any help with the output_NewestThreads bit and the code as a whole. This is a bit more complicated...
Opserty
07-15-2008, 08:10 AM
ob_start();
require_once('/home/path/file.php');
output_NewestThreads(10,"36");
$includedphp = ob_get_contents();
ob_end_clean();
Tired that? (use the global_setup_complete hook, global_start is useless when things go wrong).
Gladius2007
07-15-2008, 02:27 PM
That's exactly the code I've been trying, but wherever I use it, the page goes blank... I've been using global_start and now tried with global_setup_complete and it was the same thing - completely blank page, i.e. it kills the entire page.
Opserty
07-15-2008, 03:08 PM
Hmm, try it on a random page see if it works there. Else put it directly in a vBulletin PHP file temporarily and try it then.
Gladius2007
07-15-2008, 04:20 PM
What kind of a random page do you mean?
And which vB file would I be least likely to mess up to test it in? I haven't modified any vB files before and I'm not a coder so...
Opserty
07-15-2008, 07:48 PM
Set up a separate test board and develop on there.
(By random page I mean just a normal plain PHP Page)
Gladius2007
07-15-2008, 10:21 PM
Ok, I've tried using this code, and I get a blank page on a test page too:
<?php
ob_start();
require_once('/home/path/file.php');
output_NewestThreads(10,"36");
$includedphp = ob_get_contents();
ob_end_clean();
bla bla $includedphp bla bla
?>
I'm not sure if my code there is as it should be to use on a separate page though.
Dismounted
07-16-2008, 10:01 AM
If you want to get the latest threads, you can just query the database.
Gladius2007
07-16-2008, 12:46 PM
That's what the script does, only it's been extensively modified so it's not just that... I'd really appreciate it if someone could tell me how to get it to work as specified above, if it's possible. That'd be the easiest solution for me...
Gladius2007
07-17-2008, 03:39 PM
Anyone?
Marco van Herwaarden
07-18-2008, 10:29 AM
Where did you put the code of post #9?
Also it is a bit difficult for us to tell what is going wrong if we do not even know what this script does.
Gladius2007
07-18-2008, 02:01 PM
I put it inside a blank test.php page (with the correct path, of course).
The script is simply a modified version of the vBExternal mod; the output in this case is the 10 latest posts in the forum.
Marco van Herwaarden
07-19-2008, 09:17 AM
The code as posted in post #9 is how you would (with some minor correction) use in a plugin. This is not the same as coding a seperate page (script). See the article section on how to code extra pages.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.