SlideShare a Scribd company logo
Building a Joomla
Module
Cory Webb

Joomla Day Chicago 2017

CoryWebbMedia.com

CWExtensions.com

@corywebb
Who is this guy?
• Joomla developer since 2003
(Mambo)

• Owner Cory Webb Media &
CWExtensions.com

• Course creator for
OSTraining.com

• Author of Beginning Joomla
Web Site Development (Wrox,
2009)
Agenda
• Build a module to display a Joomla article

• Hello World

• Database query

• Display the article

• Add a helper file

• Add a template layout
Get the Module
https://cwextensions.com/jday-chicago
Build the Module
• Create folder named mod_article_display

• Add 2 files: 

mod_article_display.php

mod_article_display.xml

• Add language files: 

en-GB.mod_article_display.ini

en-GB.mod_article_display.sys.ini

• Discover install
Hello World
• Display “Hello World” in the module output

• Edit mod_article_display.php



defined(‘_JEXEC’) or die;

echo ‘<h3>Hello world!</h3>’;

• Publish the module
Database Query
• Get the article ID



$article_id = $params->get(‘article_id’);

• Create the query



$db = JFactory::getDbo();

$query = $db->getQuery(true);

$query->select(‘*’)->from(‘#__content’)->where(‘id = ‘ . $article_id);

$db->setQuery($query);

• Load the article



$article = $db->loadObject();
Display the article
• Get a link to the article with ContentHelperRoute



JLoader::register(‘ContentHelperRoute', JPATH_SITE . '/components/com_content/
helpers/route.php');

$article->slug = $article->id . ‘:’ . $article->alias;

$article->link = JRoute::_(

ContentHelperRoute::getArticleRoute(

$article->slug, $article->catid, $article->language

)

);

• Display the article



echo ‘<h3><a href=“’ . $article->link . ‘“>’ . $article->title . ‘</a></h3>’;

echo ‘<div class=“article-display-article”>’ . $article->introtext . ‘</div>’;

echo ‘<p><a href=“‘ . $article->link . ‘“ class=“read-more”>Read More</a></p>’;
Add a Helper File
• helper.php



class ModArticleDisplayHelper {…}

• Load the helper class



JLoader::register('ModArticleDisplayHelper', __DIR__ . ‘/helper.php');

• Move logic to helper



$article = ModArticleDisplayHelper::getArticle($params);
Add a Template Layout
• tmpl/default.php

• Load the template



require JModuleHelper::getLayoutPath('mod_article_display', $params->get('layout',
‘default'));
Questions/Comments

More Related Content

PPTX
How Joomla! builds a webpage (annotated)
PPTX
JoomlaDay Chicago 2017 Keynote Address
PDF
What is jQuery?
PPTX
Introduction to jquery mobile with Phonegap
PPTX
Module 3 - Intro to Bootstrap
PDF
Shriver Center for Poverty Law: Website Training
PDF
State of jQuery June 2013 - Portland
PPTX
Building a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
How Joomla! builds a webpage (annotated)
JoomlaDay Chicago 2017 Keynote Address
What is jQuery?
Introduction to jquery mobile with Phonegap
Module 3 - Intro to Bootstrap
Shriver Center for Poverty Law: Website Training
State of jQuery June 2013 - Portland
Building a Simple Mobile-optimized Web App Using the jQuery Mobile Framework

What's hot (20)

PDF
Great Responsive-ability Web Design
PDF
jQueryMobile Jump Start
PDF
Front-End Frameworks: a quick overview
PDF
HTML CSS JavaScript jQuery Training
PPT
Introducing the JotSpot Data Model and API
PPT
Joomla! Templates and Comparison of Frameworks
PDF
Web Components v1
PPTX
What’s new in joomla 3.7
PDF
Responsive Web Design: Clever Tips and Techniques
PDF
jQuery Conference Toronto
PDF
Forms as Structured Content
PDF
"Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin...
PPTX
jQuery - the world's most popular java script library comes to XPages
PDF
Component Driven Design and Development
PPTX
Front End Web Development Basics
PPTX
CORNELL DRUPAL CAMP 2015: One Content Type to Rule Them All
PDF
Decoupling the Front-end with Modular CSS
PPT
Wywiwyg and Drupal
PDF
A practical guide to building websites with HTML5 & CSS3
PPTX
Web Development
Great Responsive-ability Web Design
jQueryMobile Jump Start
Front-End Frameworks: a quick overview
HTML CSS JavaScript jQuery Training
Introducing the JotSpot Data Model and API
Joomla! Templates and Comparison of Frameworks
Web Components v1
What’s new in joomla 3.7
Responsive Web Design: Clever Tips and Techniques
jQuery Conference Toronto
Forms as Structured Content
"Responsive Web Design: Clever Tips and Techniques". Vitaly Friedman, Smashin...
jQuery - the world's most popular java script library comes to XPages
Component Driven Design and Development
Front End Web Development Basics
CORNELL DRUPAL CAMP 2015: One Content Type to Rule Them All
Decoupling the Front-end with Modular CSS
Wywiwyg and Drupal
A practical guide to building websites with HTML5 & CSS3
Web Development
Ad

Similar to Building a Joomla Module (16)

PPTX
Develop Basic joomla! MVC component for version 3
PPTX
How to Build a Website using Joomla
PPT
Joomla 3 JLayout's - Joomladay Netherlands 2014 #jd14nl
PPT
Redlinesoft Joomla Basic Workshop
ODP
Joomla Basics
DOCX
How to Develop Your First Ever Joomla Template?
PPTX
Joomla Templates101
PPT
Joomla basic-iii undersrtanding-installing-configuring-joomla-extensions
PDF
Joomla 3.0 made easy (english)
PDF
joomla Training in Hyderabad
PDF
PPT
Jump to Joomla - Barcamp Nashville 2010
PPT
Jump to Joomla - Barcamp Nashville 2010
PDF
Basics of Joomla!
PDF
Joomla 101
PDF
Joomla 3.4 Made Easy
Develop Basic joomla! MVC component for version 3
How to Build a Website using Joomla
Joomla 3 JLayout's - Joomladay Netherlands 2014 #jd14nl
Redlinesoft Joomla Basic Workshop
Joomla Basics
How to Develop Your First Ever Joomla Template?
Joomla Templates101
Joomla basic-iii undersrtanding-installing-configuring-joomla-extensions
Joomla 3.0 made easy (english)
joomla Training in Hyderabad
Jump to Joomla - Barcamp Nashville 2010
Jump to Joomla - Barcamp Nashville 2010
Basics of Joomla!
Joomla 101
Joomla 3.4 Made Easy
Ad

More from Cory Webb (7)

PDF
Demystifying Gutenberg Blocks - Understanding the first steps to becoming a G...
PDF
Create Custom Page Builders with Gutenberg and ACF Blocks
PDF
Building your first Gutenberg block
PDF
Responsive Web Design
PDF
You're doing it wrong! Git it right!
ODP
Mobile Joomla Stragies & Techniques
PDF
Getting Social With Joomla
Demystifying Gutenberg Blocks - Understanding the first steps to becoming a G...
Create Custom Page Builders with Gutenberg and ACF Blocks
Building your first Gutenberg block
Responsive Web Design
You're doing it wrong! Git it right!
Mobile Joomla Stragies & Techniques
Getting Social With Joomla

Recently uploaded (20)

PPTX
522797556-Unit-2-Temperature-measurement-1-1.pptx
PDF
Exploring VPS Hosting Trends for SMBs in 2025
PPTX
Digital Literacy And Online Safety on internet
PDF
Paper PDF World Game (s) Great Redesign.pdf
PPTX
Slides PPTX World Game (s) Eco Economic Epochs.pptx
PPTX
newyork.pptxirantrafgshenepalchinachinane
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
PPT
tcp ip networks nd ip layering assotred slides
PDF
SASE Traffic Flow - ZTNA Connector-1.pdf
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
PDF
The New Creative Director: How AI Tools for Social Media Content Creation Are...
PPTX
Introuction about WHO-FIC in ICD-10.pptx
PPTX
Funds Management Learning Material for Beg
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PPT
Ethics in Information System - Management Information System
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
PDF
Smart Home Technology for Health Monitoring (www.kiu.ac.ug)
PDF
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
PDF
FINAL CALL-6th International Conference on Networks & IOT (NeTIOT 2025)
PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
522797556-Unit-2-Temperature-measurement-1-1.pptx
Exploring VPS Hosting Trends for SMBs in 2025
Digital Literacy And Online Safety on internet
Paper PDF World Game (s) Great Redesign.pdf
Slides PPTX World Game (s) Eco Economic Epochs.pptx
newyork.pptxirantrafgshenepalchinachinane
Job_Card_System_Styled_lorem_ipsum_.pptx
tcp ip networks nd ip layering assotred slides
SASE Traffic Flow - ZTNA Connector-1.pdf
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
The New Creative Director: How AI Tools for Social Media Content Creation Are...
Introuction about WHO-FIC in ICD-10.pptx
Funds Management Learning Material for Beg
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
Ethics in Information System - Management Information System
Tenda Login Guide: Access Your Router in 5 Easy Steps
Smart Home Technology for Health Monitoring (www.kiu.ac.ug)
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
FINAL CALL-6th International Conference on Networks & IOT (NeTIOT 2025)
INTERNET------BASICS-------UPDATED PPT PRESENTATION

Building a Joomla Module

  • 1. Building a Joomla Module Cory Webb Joomla Day Chicago 2017 CoryWebbMedia.com CWExtensions.com @corywebb
  • 2. Who is this guy? • Joomla developer since 2003 (Mambo) • Owner Cory Webb Media & CWExtensions.com • Course creator for OSTraining.com • Author of Beginning Joomla Web Site Development (Wrox, 2009)
  • 3. Agenda • Build a module to display a Joomla article • Hello World • Database query • Display the article • Add a helper file • Add a template layout
  • 5. Build the Module • Create folder named mod_article_display • Add 2 files: 
 mod_article_display.php
 mod_article_display.xml • Add language files: 
 en-GB.mod_article_display.ini
 en-GB.mod_article_display.sys.ini • Discover install
  • 6. Hello World • Display “Hello World” in the module output • Edit mod_article_display.php
 
 defined(‘_JEXEC’) or die;
 echo ‘<h3>Hello world!</h3>’; • Publish the module
  • 7. Database Query • Get the article ID
 
 $article_id = $params->get(‘article_id’); • Create the query
 
 $db = JFactory::getDbo();
 $query = $db->getQuery(true);
 $query->select(‘*’)->from(‘#__content’)->where(‘id = ‘ . $article_id);
 $db->setQuery($query); • Load the article
 
 $article = $db->loadObject();
  • 8. Display the article • Get a link to the article with ContentHelperRoute
 
 JLoader::register(‘ContentHelperRoute', JPATH_SITE . '/components/com_content/ helpers/route.php');
 $article->slug = $article->id . ‘:’ . $article->alias;
 $article->link = JRoute::_(
 ContentHelperRoute::getArticleRoute(
 $article->slug, $article->catid, $article->language
 )
 ); • Display the article
 
 echo ‘<h3><a href=“’ . $article->link . ‘“>’ . $article->title . ‘</a></h3>’;
 echo ‘<div class=“article-display-article”>’ . $article->introtext . ‘</div>’;
 echo ‘<p><a href=“‘ . $article->link . ‘“ class=“read-more”>Read More</a></p>’;
  • 9. Add a Helper File • helper.php
 
 class ModArticleDisplayHelper {…} • Load the helper class
 
 JLoader::register('ModArticleDisplayHelper', __DIR__ . ‘/helper.php'); • Move logic to helper
 
 $article = ModArticleDisplayHelper::getArticle($params);
  • 10. Add a Template Layout • tmpl/default.php • Load the template
 
 require JModuleHelper::getLayoutPath('mod_article_display', $params->get('layout', ‘default'));