Professional Documents
Culture Documents
1 Module
Overview Presentation
1.
Extensions, an introduction 2. Module basics 3. Database >>>Sheetsvia:www.db8.nl<<< 4. OOP 5. Parameters 6. Language File 7. Views 8. Parameters Advanced 9. Package 10. Update
Peter Martin joomladagen.nl 20+21 april 2013
1. Extensions, an introduction
1. Extensions 5 types
Extending Joomla's functionality: 1. Components 2. Modules 3. Plugins 4. Templates 5. Language Files
1. Extensions Component
Most importantdetermines functionality One component at a time Activation via URL + &option=com_componentname Management in back-end: Components > Component name exception: com_content Multiple Modi: CRUD (Create, Read, Update, Delete) Example: com_content
1. Extensions Module
Supportive, Widget, only display to screen (Module Positie) Multiple modules at a time. Activation via menu item: URL + &Itemid=x Management in back-end: Extensions > Module Manager: ACL, order, parameters 1 mode: Read (Display) Example: mod_breadcrumbs
1. Extensions Plugin
Supportive. Works invisible in background. Multiple plugins at a time Activation via certainevents (of hooks) in components Management in back-end: Extensions > Plugin Manager: ACL, order, parameters 1 mode Example: Content emailcloak Plugin
(M) (C)
C Processing P Search in database table P Search in database table P Search in database table C Results
Component
Plugin
(P)
Module Positions:
Extensions > Template Manager > Preview Module Positions: enabled URL + ?tp=1
Code
2. Module basics
2. Module basics
Location:
Front-end: /modules/mod_name Back-end: /administrator/modules/mod_name mod_name.php code mod_name.xml installation & parameters #__extensions
name=Module Name type=module element=mod_name folder={emply} client_id: 0 = front-end, 1 = back-end
Files:
Database reference
Database
tabel: #__weblinks
Joomla's
Weblinks Module
<?php defined('_JEXEC') or die; echo "Peter's Recent Weblinks!"; mod_db8latestweblinks.xml {next sheet}
Installation:
Extensions
> Extension Manager > Discover Extensions > Module Manager > [New]
3. Module Database
3. Module Database
Joomla Database Object
1.Call Joomla's Database Object 2.Instantiate an empty Query Object 3.Build Query Object
do NOT use hardcoded MySQL! SELECT * FROM #__weblinks ORDER BY created DESC
4.Feed Query Object to Database Object 5.Retrieve Results from Database Object
3. Module Database
mod_db8latestweblinks.php
defined('_JEXEC')ordie; $db=Jfactory::getDbo(); $query=$db>getQuery(true); $query>select('*') >from('#__weblinks') >order('createdDESC'); $db>setQuery($query,0,7); $items=$db>loadObjectList(); ?> <ul> <?phpforeach($itemsAS$item):?> <li><?phpecho$item>title;?></li> <?phpendforeach;?> </ul>
3. Module Database
Debug: echo "sql = $query"; print_r($items); HTML
Oriented Programming
MVC
(Model/View/Controller) architecture:
output!
the same
5. Parameters
5. Parameters
Flexibility
Categories Limit results Target Window Follow/No Follow Display: Date, Description (hover), Hits Count clicks / or not Display: Published / unpublished
.xml
5. Parameters Choices
/modules/mod_db8latestweblinks/
mod_db8latestweblinks.xml
<config> <fieldsname="params"> <fieldsetname="basic"> <field/> </fieldset> <fieldsetname="advanced"> <field/> </fieldset> </fields> </config>
Peter Martin joomladagen.nl 20+21 april 2013
5. Parameters Choices
/modules/mod_db8latestweblinks/
mod_db8latestweblinks.xml
<fieldsetname="basic"> <fieldname="catid" type="category" extension="com_weblinks" multiple="true" required="true" label="Category" description="SelectWeblinkcategory"/> <fieldname="count" type="text" default="5" label="Number" description="DisplaynumberWeblinks"/> </fieldset>
Peter Martin joomladagen.nl 20+21 april 2013
5. Parameters
/modules/mod_db8latestweblinks/
helper.php
staticfunctiongetItems($params){ $db=Jfactory::getDbo(); $query=$db>getQuery(true); $query>select('*') >from('#__weblinks') >order('createdDESC'); $catid=$params>get('catid'); if(is_array($catid)){ if($catid[0]!=null){ $catid=implode(',',$catid); $query>where('catidIN('.$catid.')'); } } $db>setQuery($query,0,$params>get('count',5)); $rows=$db>loadObjectList(); return$rows; }
5. Parameters Choices
6. Language File
6. Language File
Flexibility
In language files folder: /language/en-GB/en-GB.mod_name.ini /language/en-GB/en-GB.mod_name.sys.ini Or in Module, e.g.: /modules/mod_db8latestweblinks/language/en-GB/ en-GB.mod_db8latestweblinks.ini /modules/mod_db8latestweblinks/language/en-GB/ en-GB.mod_db8latestweblinks.sys.ini
6. Language File
/modules/mod_db8latestweblinks/ mod_db8latestweblinks.xml
<fieldname="catid" type="category" extension="com_weblinks" multiple="true" required="true" label="JCATEGORY" description="MOD_DB8LATESTWEBLINKS_ FIELD_CATEGORY_DESC"/> <fieldname="count" type="text" default="5" label="MOD_DB8LATESTWEBLINKS_FIELD_COUNT_LABEL" description="MOD_DB8LATESTWEBLINKS_ FIELD_COUNT_DESC"/> </fieldset>
6. Language File
6. Language File
/language/en-GB/en-GB.mod_db8latestweblinks.ini
MOD_DB8LATESTWEBLINKS_FIELD_CATEGORY_DESC="Choosetheweblinkscategorytodisplay" MOD_DB8LATESTWEBLINKS_FIELD_COUNT_DESC="Numberofweblinkstodisplay" MOD_DB8LATESTWEBLINKS_FIELD_COUNT_LABEL="Count"
/language/en-GB/en-GB.mod_db8latestweblinks.sys.ini
MOD_DB8LATESTWEBLINKS="WeblinksLatest" MOD_DB8LATESTWEBLINKS_XML_DESCRIPTION="Thismodulesdisplaysthelatestweblinks fromacategorydefinedintheWeblinkscomponent."
/language/de-DE/de-DE.mod_db8latestweblinks.ini
MOD_DB8LATESTWEBLINKS="WeblinksNeueste" MOD_DB8LATESTWEBLINKS_XML_DESCRIPTION="DiesesModulzeigtdieallerneuestenWeblinks auseinerKategorieinderWeblinksKomponentedefiniert." MOD_DB8LATESTWEBLINKS_FIELD_CATEGORY_DESC="WhlenSiedieKategorieWebLinks angezeigtwerden" MOD_DB8LATESTWEBLINKS_FIELD_COUNT_LABEL="Anzahl" MOD_DB8LATESTWEBLINKS_FIELD_COUNT_DESC="AnzahlanangezeigtenWeblinks"
/language/de-DE/de-DE.mod_db8latestweblinks.sys.ini
MOD_DB8LATESTWEBLINKS="WeblinksNeueste" MOD_DB8LATESTWEBLINKS_XML_DESCRIPTION="DiesesModulzeigtdieallerneuestenWeblinks auseinerKategorieinderWeblinksKomponentedefiniert."
6. Language File
7. Views
7. Views
View
Change
Create
8. Parameters Advanced
8. Parameters Advanced
Advanced
Options
Alternative Layout (see 7. Views) Module Class Suffix Caching Cache Time
8. Parameters Advanced
<fieldsetname="advanced"> <fieldname="moduleclass_sfx" type="text" label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL" description="COM_MODULES_FIELD_MODULECLASS_SFX_DESC"/> <fieldname="cache" type="list" default="1" label="COM_MODULES_FIELD_CACHING_LABEL" description="COM_MODULES_FIELD_CACHING_DESC"> <optionvalue="1">JGLOBAL_USE_GLOBAL</option> <optionvalue="0">COM_MODULES_FIELD_VALUE_NOCACHING</option> </field> <fieldname="cache_time" type="text" default="900" label="COM_MODULES_FIELD_CACHE_TIME_LABEL" description="COM_MODULES_FIELD_CACHE_TIME_DESC"/> <fieldname="cachemode" type="hidden" default="static"> <optionvalue="static"></option> </field> </fieldset>
package: mod_name_j3x_v2.zip
Language
HTML
/tmpl/default.php /tmpl/with-date.php
TEST!
10. Update
10. Update
In
your Module:
Manifest .xml file with <updateservers>
On
mod_db8latestweblinks.xml
Do
The
Questions?
Questions?
Presentation
available at www.db8.nl
Used Photos
Speed Typing - Matthew Bowden http://www.sxc.hu/photo/275499 Motherboard 4 - Lisa Zanchi http://www.sxc.hu/photo/103914 ram Mohamed Riffath http://www.sxc.hu/photo/487296 lots of files 2 - Michael & Christa Richert http://www.sxc.hu/photo/1370555 Blank E-Box for Software etc 6 - Przemyslaw Szczepanski, http://www.sxc.hu/photo/950048 switches - "trhaynes", http://www.sxc.hu/photo/56670 Bengali Keyborad - Mohammad Jobaed Adnan http://www.sxc.hu/photo/676844 san sebastian views 1 - ibon san martin http://www.sxc.hu/photo/94018 Communications Receiver - John Munsch http://www.sxc.hu/photo/260775 Fragile Parcel - Richard Dudley http://www.sxc.hu/photo/1279274 Sparks - Hector Landaeta http://www.sxc.hu/photo/1184243 signs signs - Jason Antony, http://www.sxc.hu/photo/751034 Face - Questions - Bob Smith, http://www.sxc.hu/photo/418215 Joomladay 2013 Germany 58