MyBB Community Forums

Full Version: Why Plugin inside a directory did not recognized?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys,

I just wondered that MyBB did not read a plugin that put inside a directory. I realized this when I'm developing a plugin that consist of few files. So, instead of putting all my files inside plugins directory, I group my plugin files into a directory.

But when I want to activate the plugin through admin panel, my plugin did not exists Huh. So, I made a little trick by creating a file then requiring all the files inside the directory.

I hope in future release of MyBB we just can put a plugin inside a directory just like what wordpress did in their plugin system.

Thanks Smile
Putting it in a directory is somewhat unnecessary. You can quite easily add a directory for your plugin's dependent files.

Eg:
/inc/plugins
|- myplugin.php
|- myplugin_files/
|--- include_file.php
|--- another_include_file.php
(2009-02-08, 01:34 PM)Yumi Wrote: [ -> ]Putting it in a directory is somewhat unnecessary. You can quite easily add a directory for your plugin's dependent files.

Eg:
/inc/plugins
|- myplugin.php
|- myplugin_files/
|--- include_file.php
|--- another_include_file.php

Hi Yumi,

Thanks, that was I did to do the trick.

I think is better if MyBB plugin system would search recursively inside a directory so we did not need to put a file outside our directory plugin. The example is wordpress plugin.

Thanks Big Grin
I doubt wordpress searches recursively but rather expects a plugin to be a directory rather :/

I like the way MyBB does it
Going through each directory would be rediculous. Not to mention there's no way to distinguish a plugin file from another file - unless you add yet another filter.
You should only need to check for a .php file that has the same name as the directory, and the file is just moving from the 'inc/plugins/' dir to a sub-dir without any new file to check
I split my Google SEO plugin up in the latest version 0.5, so there is google_seo.php in the inc/plugins/ folder and all other code is distributed over several files in inc/plugins/google_seo/*

It's a bit of a hack (especially moving the plugin info / install / activate etc. routines in a separate file), but it works fine and it definitely pays off in terms of code readability. Haven't done much performance testing to find out wether using several files hurts the loading process much. But I guess if it did, MyBB wouldn't consist of dozens of files either.

Wether you put pluginname.php in the plugins dir and all other files in a subdir pluginname/, or wether MyBB looks in pluginname/pluginname.php, I don't think it matters much. Very few plugins are large enough to require a directory by themselves anyway.