joomla plugin & module develpment - presented at sydney jug 09/04/2013

Post on 10-May-2015

2.610 Views

Category:

Technology

4 Downloads

Preview:

Click to see full reader

DESCRIPTION

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.

TRANSCRIPT

Joomla Plugin & Module Develpment

Tim Plummerhttp://twitter.com/bfsurvey

Presented at Sydney JUG 09/04/2013

What is a plugin?

What is a module?

Tools you need

• Web Server & PHP & MySQL (XAMPP)

• Text editor or IDE (Textpad / Notepad++ or Eclipse / Netbeans)

• Web browser (Firefox with firebug)

Getting started with plugins

• Can be as simple as two files– yourplugin.xml– yourplugin.php

• Located in /plugins/plugintype/yourplugin• Triggered by events

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)

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

Types of plugins

• Authentication• Captcha• Content• Editors• Editors-XTD• Extension

• Quick Icon• Search• Smart Search (finder)• User• System

Plugin Event Triggers

• Authentication– onUserAuthenticate– onUserAuthorisationFailure

• Captcha– onCheckAnswer– onDisplay– onInit

• Content– onContentAfterDelete– onContentAfterDisplay– onContentAfterSave– onContentAfterTitle– onContentBeforeDelete– onContentBeforeDisplay– onContentBeforeSave– onContentChangeState– onContentPrepare– onContentPrepareData– onContentPrepareForm– onContentSearch– onContentSearchAreas

Plugin Event Triggers…cont

• Editors– onDisplay– onGetContent– onGetInsertMethod– onInit– onSave– onSetContent

• Editors-XTD– onDisplay

• Extension– onExtensionAfterInstall– onExtensionAfterSave– onExtensionAfterUninstall– onExtensionAfterUpdate– onExtensionBeforeInstall– onExtensionBeforeSave– onExtensionBeforeUninst

all– onExtensionBeforeUpdate

Plugin Event Triggers…cont

• Quick Icon– onGetIcons

• Search– onContentSearchAreas– onContentSearch

• Smart Search– onFinderAfterDelete– onFinderAfterSave– onFinderBeforeSave– onFinderCategoryChangeState– onFinderChangeState

• System– onAfterDispatch– onAfterInitialise– onAfterRender– onAfterRoute

• User– onUserAfterDelete– onUserAfterSave– onUserBeforeDelete– onUserBeforeSave– onUserLogin– onUserLogout

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

Set Error Reporting to Maximum

Only do

this on a

dev site

Demo time…

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

Types of modules

• Two types– Frontend Module (aka site)• /modules/yourmodule

– Backend Module (aka administrator)• /administrator/modules/yourmodule

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)

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.

Helper

• helper.php file located in module folder• Talks to the database and prepares data for

the view.

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!).

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.

Demo time…

Now you are ready to start creating your own plugins and modules

Questions?

Tim Plummer@bfsurvey

tim@tamlyncreative.com.au

top related