MyBB Community Forums

Full Version: Randomly selected text display
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I've been working on a plugin for my MyBB forum for a while now. But I've hit an impasse. I've gotten basically everything done and by rights it should be working properly... I mean the front end aspects work as intended. But I can't for the life of me get the ACP side working.

The ACP side should work, but when I go to click on the link to load the plugin, this is the screen I get. I don't think the issue is in the admin/index.php part so much as somewhere in the code I've written.

I've stared at the code for this for a while and I'm just not seeing where the issue actual stems from. (I'm sure it's something simple that I'm overlooking.) So can someone (who knows a bit more about PHP) please have a look and help me figure this out?


The plugin is here (or a slightly newer text version here.)

Notes:
1- Please don't install on live sites. It's not ready for that yet. I'm not responsible for any issues/errors or problems that result from your use of this code. You've been warned.
2- In order to get the replacement aspect to work you have to add {randomplot_chosen} somewhere in your templates (preferably on your index).
3- You can manually add content (to get swapped by the code) with PHPMyAdmin and the swap function does work.
Find:
function randomplot_forum_action_handler(&$actions){   
$actions['randomplot'] = array('active' => 'randomplot', 'file' => 'randomplot');
}

Replace With:

function randomplot_forum_action_handler(&$actions){   
$actions['randomplot'] = array('active' => 'randomplot', 'file' => 'randomplot.php');
}
Doesn't make any difference (for me) other than changing the error message to:

Quote:Warning [2] require(D:\Xampp\htdocs\mod_dev/admin/modules/forum/randomplot.php)...

...
...


Fatal error: require(): Failed opening required 'D:\Xampp\htdocs\mod_dev/admin/modules/forum/randomplot.php'

So that may be part of the problem, but it doesn't seem to be all of it.
Do you actually have a file called randomplot.php in your admin/modules/forum directory?
I don't have randomplot.php there.
(I have it in the inc/plugins folder only...)

If I do put a copy of randomplot.php into the admin/modules/forum section then it just tells me it cannot redeclare randomplot_info then each function in turn as they're removed... Which makes sense as they should already exist and be called in the existing php file in the inc/plugins folder.
Whatever code needs to execute in the Admin CP put in randomplot.php file in your /admin/modules/forum directory. The plugin file just needs the hooks for the Admin CP. If you want an example, take a look at my Social Groups plugin on Github. Look first at the plugin file which is in the inc/plugins folder. Then social_groups.php in the admin/modules/user folder.
I've split the files now and left the hooks in inc/plugins part... though the ACP part is throwing a new error now...

Quote:Fatal error: Call to undefined function randomplot_admin() in D:\Xampp\htdocs\mod_dev\inc\class_plugins.php on line 101

But that's another error which doesn't make sense to me. I mean line 101 is:
$returnargs = $func($arguments);

And I'm not sure why it'd be throwing an error here since randomplot_admin shouldn't have a need for an argument in it... Should it?
Get rid of the line that says $plugins->add_hook("admin_load", "randomplot_admin");
You will use your file in /admin/modules/forum to handle that.
Ah, I should have noticed that.

So that's done. On the upside it's not displaying any more errors. On the downside... it's not displaying anything (just a completely blank white screen).
So something's off in the rendering of the output somewhere.
If you kept it as being called a function then you need to actually call the function in that file.
Pages: 1 2