MyBB Community Forums

Full Version: Test Plugin for new developers
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
I decided to make something this weekend for new developers that are interested in making plugins for MyBB but don't really know how.

The plugin is attached to this post along with the licence (LGPL 3) and its language file.

About every line is commented and I hope I've made things clear. Note that this is not supposed to teach you how to code in PHP but how to apply your PHP programming knowledge to developing MyBB plugins.

Here's what the plugin does:
  • Installation:
    • Adds two settings.
    • Adds one table.
  • Activation:
    • Adds templates.
    • Edits existing templates.
  • Deactivation:
    • Removes templates.
    • Removes edits made during the activation process.
  • Uninstallation:
    • Removes settings.
    • Drops table.
  • Allows users to input messages from the index page.
  • The messages are shown on the index page and under every post, depending on the values of the two settings (they control if the messages are shown on index and at the bottom every post).

Even though the plugin is fairly simple it may be possible that I forgot something or accidentally wrote something incorrectly so in case you notice something wrong please say so.

I'm leaving this thread open in case you have any questions regarding this plugin, however this thread is not the place to ask for anything else besides that.
Excellent but I'd call it "example" instead since it really don't test anything.
Good one. We're most likely going to use this one in 1.6.7 instead of the hello world one so yeah changing to to example plugin might definitely be a good idea.
Just noticed you're now on dev team. Congrats.
^ It's been months.
do you think that adding and removing templates in the activate/deactivate functions is the best? I prefer to install and remove new templates during install/uninstall and then only make the edits to existing templates during activate to make the plugin visible.
(2011-12-21, 03:48 AM)pavemen Wrote: [ -> ]do you think that adding and removing templates in the activate/deactivate functions is the best? I prefer to install and remove new templates during install/uninstall and then only make the edits to existing templates during activate to make the plugin visible.

Adding and removing templates from the global templates should be done in the install/uninstall functions. However any per theme templates or templatesets should be done during activation/deactivation in addition to template edits.
my reasoning for keeping all adds/deletes with install and uninstall is that if a user modifies the template, those edits are gone when the plugin is deactivated. at least the simple edits of inserting a template variable is easy to modify. changing an entire template can be more of a PITA.

Just my opinion, but looking for what others feel is the norm.
I prefer it like this because plugin upgrades that require template updates can be done very easily.
@labrocca for 4 months!
(2011-12-21, 07:46 AM)Pirata Nervo Wrote: [ -> ]I prefer it like this because plugin upgrades that require template updates can be done very easily.
@labrocca for 4 months!

Except that then the users lose all the customizations they made to said templates. Definitely the wrong way to do it. The right way? Use the template versions! Thats why the stupid things are there. Then you can do a version compare on reactivation and warn the user that there is an updated template... output it in some way and make them compare them I guess. I've got this on my TODO for my plugins.
Pages: 1 2 3 4