Plugin tutorial?

Plugin tutorial?

by Fred Riley -
Number of replies: 6

I'm after developing a new plugin modelled on the Label plugin, to add another Resource* to the Add Activity/Resource menu. Is there a plugin/module development tutorial around anywhere? There is the NEWMODEL Documentation, but not only is that still in draft, it applies only to v1.9. Is there anything a bit more up-to-date?

I'm aware of the activity modules documentation, and also that I could clone /mod/label and play around with that, trying to learn by trial and error through code mooching. I'm also aware of the YouTube video "

" but that's an hour long, and my learning style is verbal, not visual.

However, I found the Blocks and Themes tutorials very useful as starting points, and they saved me a lot of fumbling around time by describing the anatomy of these, so if there's something for modules/plugins (I'm still unsure of the correct terminology) that would be useful for this field mouse snuffling around the undergrowth of the fearsome Moodle jungle. In my experience, it's better to have a trail guide (or even a forest ranger) to help you explore, than to fumble around at random.

Fred

* Except that it looks like 'resource' is now a deprecated term, and that everything is an 'activity'.

Average of ratings: Useful (1)
In reply to Fred Riley

Re: Plugin tutorial?

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers

There is a big fat hole in Moodle about here. Sadly there just is not enough information out there for new plugin developers.

But would you believe everyone on this forum was once where you are now. The best advice, currently, is to get started with a code template if there is one. If not choose a mod that comes closest to doing what you want.  Then modify it as best you can, and importantly pop back here often to ask questions. 

I have a few tutorials that I have given at webinars and moots. I started to put some of that information on a new blog, but as always got distracted. However your plight has inspired me to get started again. This page on it might be * a little* use. 

http://moodling.net/2014/05/21/analysis-of-a-plugin-add-on/


Average of ratings: Useful (5)
In reply to Justin Hunt

Re: Plugin tutorial?

by Fred Riley -

Thanks, Justin, and I'm sorry I missed your reply until now. It's the 'getting started' bit that's the main hurdle for me. The Activity Modules doc is great for description of the folder structure and contents of a module, but it doesn't actually say how you start creating a new module. That is, you can clone an existing module easily enough by simply copying the folder and pasting it into the module folder, but it's unclear what the developer needs to do to edit the clone to create a new module.

So, for instance, I create the folder /mod/freds-label/ by copying /mod/label. I want to tweak it so that:

  • it's named "Fred's label"
  • it can be installed in moodle
  • it shows up in "Add an activity or resource"

That would be a starter for ten, after which I could start playing around with the functionality. It's not clear to me, from the Activity Modules page and your blog post, which file(s) need to be edited.

I'm aware, from my blocks experience, that the best (only?) way of developing Moodle plugins/blocks/modules/bits is to copy existing ones and modify them, rather than writing from scratch. What the Blocks Tutorial is good at is explaining which files need to be modified and how. If there were something similar for modules that would be really handy.

A small thing: the link on your blog post has gone 404.

Cheers

Fred

Average of ratings: Useful (1)
In reply to Fred Riley

Re: Plugin tutorial?

by Conn Warwicker -
Picture of Core developers Picture of Plugin developers

I can whip you up blank template for a new resource plugin later on this evening if you want. So you can see what you will need.

In reply to Conn Warwicker

Re: Plugin tutorial?

by Jim Thorpe -

Hi Conn, I'd find that very useful as well. Could you please put a link to it when you have opportunity.  Thanks Jim

In reply to Conn Warwicker

Re: Plugin tutorial?

by Fred Riley -

Thanks, Conn. I'm sure that that would be useful to the community, not just myself and Jim. I found  Daniel Neis Araujo's NEWBLOCK template (linked to at the bottom of the Blocks Tutorial) to be very useful in block development.

I'm sorry about coming back late on this again - I keep missing thread titles in my digest, and the site doesn't email me on thread updates despite subscribing to threads, so I don't get notification of replies sad

Fred

Average of ratings: Useful (1)
In reply to Fred Riley

Plugin tutorial - help?

by Dennis Davis -

Hello. I found this thread by doing a search for "creating a plugin in Moodle".

We are just starting to use Moodle and are on ver 2.9.

I would like to have a way to add the "author and date" to a course or page when it is created. There will be a lot of trainers that are in different time zones, locations and areas of expertise. They will be adding content based on what they are teaching. A lot of our material will cross over into different disciplines and this would be a good way to see who added that content.

Thank you for your time and help,

Dennis

Average of ratings: Useful (1)