Joomla plugin & module develpment - Presented at Sydney JUG 09/04/2013

3,216 views
3,006 views

Published on

This is an introduction to plugin and module extension development for Joomla 3. It was presented at Sydney JUG in April 2013, and was accompanied with some live demos of a simple content plugin and simple module. If you want the source code from the live demos, feel free to get in touch with me.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,216
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
95
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Joomla plugin & module develpment - Presented at Sydney JUG 09/04/2013

  1. 1. Joomla Plugin & Module Develpment Tim Plummer http://twitter.com/bfsurveyPresented at Sydney JUG 09/04/2013
  2. 2. What is a plugin?
  3. 3. What is a module?
  4. 4. Tools you need • Web Server & PHP & MySQL (XAMPP) • Text editor or IDE (Textpad / Notepad++ or Eclipse / Netbeans) • Web browser (Firefox with firebug)
  5. 5. Getting started with plugins• Can be as simple as two files – yourplugin.xml – yourplugin.php• Located in /plugins/plugintype/yourplugin• Triggered by events
  6. 6. Installation XML (aka manifest) • yourplugin.xml file located in your plugin folder • Used when installing your plugin – tells Joomla all the files used, and the type of plugin it is. • Contains information about the plugin, such as it’s name, author, version number etc. • Has all the parameters (aka options)
  7. 7. Entry point• yourplugin.php file located in your plugin folder• This code is executed when the plugin runs, and can call other files.• Does all the hard work
  8. 8. Types of plugins• Authentication • Quick Icon• Captcha • Search• Content • Smart Search (finder)• Editors • User• Editors-XTD • System• Extension
  9. 9. Plugin Event Triggers• Authentication • Content – onUserAuthenticate – onContentAfterDelete – onUserAuthorisationFail – onContentAfterDisplay ure – onContentAfterSave• Captcha – onContentAfterTitle – onCheckAnswer – onContentBeforeDelete – onDisplay – onContentBeforeDisplay – onInit – onContentBeforeSave – onContentChangeState – onContentPrepare – onContentPrepareData – onContentPrepareForm – onContentSearch – onContentSearchAreas
  10. 10. Plugin Event Triggers…cont• Editors • Extension – onDisplay – onExtensionAfterInstall – onGetContent – onExtensionAfterSave – onGetInsertMethod – onExtensionAfterUninstall – onInit – onExtensionAfterUpdate – onSave – onExtensionBeforeInstall – onSetContent – onExtensionBeforeSave• Editors-XTD – onDisplay – onExtensionBeforeUninstall – onExtensionBeforeUpdate
  11. 11. Plugin Event Triggers…cont• Quick Icon • System – onGetIcons – onAfterDispatch• Search – onAfterInitialise – onAfterRender – onContentSearchAreas – onAfterRoute – onContentSearch • User• Smart Search – onUserAfterDelete – onFinderAfterDelete – onUserAfterSave – onFinderAfterSave – onUserBeforeDelete – onFinderBeforeSave – onUserBeforeSave – onFinderCategoryChangeState – onUserLogin – onFinderChangeState – onUserLogout
  12. 12. plg_content_joomlarocks• Hello World sucks, so instead tonight we are going to create a plugin called plg_content_joomlarocks• This plugin will find all the “Joomla!” text in articles and replace it with “Joomla Rocks” and turn this into a link that goes to www.joomla.org
  13. 13. Set Error Reporting to Maximum
  14. 14. Demo time…
  15. 15. Getting Started with modules• Slightly more complex than plugins, but still way simpler than components.• Can be as little as three files (but usually 4+) – mod_yourmodule.xml – mod_yourmodule.php – helper.php – /tmpl/default.php
  16. 16. Types of modules• Two types – Frontend Module (aka site) • /modules/yourmodule – Backend Module (aka administrator) • /administrator/modules/yourmodule
  17. 17. Installation XML (aka manifest)• mod_yourmodule.xml file located in your module folder• Used when installing your module – tells Joomla all the files used, and the type of module it is.• Contains information about the module, such as it’s name, author, version number etc.• Has all the parameters (aka options)
  18. 18. Entry Point• mod_yourmodule.php file located in your module folder• This code is executed when the plugin runs, and can call other files.• Is lazy and makes the helper and view do all the work.
  19. 19. Helper• helper.php file located in module folder• Talks to the database and prepares data for the view.
  20. 20. The View• Located in /tmpl/default.php in the module folder• Presents the data to the user• Doesn’t know where the data came from or how it is stored and doesn’t care (as Sargent Schultz would say, I know nothing!).
  21. 21. mod_random_article• Tonight we are going to create an article mod_random_article• This will randomly select an article and show the title with a link.
  22. 22. Demo time…
  23. 23. Now you are ready to start creating your own plugins and modules
  24. 24. Questions?
  25. 25. Tim Plummer @bfsurveytim@tamlyncreative.com.au

×