SlideShare une entreprise Scribd logo
1  sur  28
Télécharger pour lire hors ligne
Joomla
                           Development
                         I t ’ s   E a s i e r T h a n      Y o u
                                        T h i n k




 SourceCoast Extensions               sourcecoast.com   Intro To Joomla Development
Saturday, August 6, 11                                                                1
SourceCoast
                             A l e x A n d r e a e
                         O w n e r / D e v e l o p e r

                                 JFBConnect
           Full Facebook Integration Suite for Joomla
  * Facebook Authentication
  * Facebook Page Tab / Canvas Support
  * Like, Comment, Fanbox, Recommendations & more widgets
  * Customizeable Profile Import Into
    * JomSocial, Community Builder, Kunena, K2, Agora
  * Lots more...
          Over 60 straight 5-star reviews on the JED

 SourceCoast Extensions           sourcecoast.com   Intro To Joomla Development
Saturday, August 6, 11                                                            2
Overview


                         Module Structure

                         API Overview

                         Component Structure




 SourceCoast Extensions                 sourcecoast.com   Intro To Joomla Development
Saturday, August 6, 11                                                                  3
Joomla - MVC
                         MVC(t) – Model View Controller (template)

                         Controller – Sets up environment for the display

                         Model – Data interface

                           Generally to the database, but can 'create'
                           data if necessary

                         View – Uses the model to get data to display

                         Template – Override-able display output
 SourceCoast Extensions                 sourcecoast.com     Intro To Joomla Development
Saturday, August 6, 11                                                                    4
Modules
                         Linear code execution

                         VC(t) (no real model necessary)

                         Uses a 'helper.php' file for additional function calls

                           Can be model-like, but modules don’t have DB tables

                         Files:

                           mod_<modulename>.php and .xml

                           helpers/helper.php

                           tmpl/default.php
 SourceCoast Extensions                     sourcecoast.com         Intro To Joomla Development
Saturday, August 6, 11                                                                            5
Modules - Basics
  mod_demo.xml




                          mod_demo.php



      default.php




 SourceCoast Extensions                  sourcecoast.com   Intro To Joomla Development
Saturday, August 6, 11                                                                   6
Module Helper Files
    mod_demo.php




        helper.php

                                    * Separate out Classes/Functions


                          default.php




 SourceCoast Extensions       sourcecoast.com     Intro To Joomla Development
Saturday, August 6, 11                                                          7
Modules/Component
 mod_demo.php           Interaction

                                             * Load Component’s model
                                             * Re-Use Code!


                                             helper.php




                                                      default.php



 SourceCoast Extensions    sourcecoast.com                Intro To Joomla Development
Saturday, August 6, 11                                                                  8
Joomla API
                          Overview


 SourceCoast Extensions    sourcecoast.com   Intro To Joomla Development
Saturday, August 6, 11                                                     9
Joomla API
                         http://api.joomla.com

                            Recently updated to Joomla 1.7 API - YAY!

                         Left side, select “Joomla-Platform” package

                         Bookmark, cuddle up to, and learn to love this page

                         “Classes” describes

                            JFactory – Most widely used

                            JRoute – Get URL for specific component/view/task

                         “Application” describes

                            Every other Joomla function (many inherited into JFactory)

 SourceCoast Extensions                          sourcecoast.com        Intro To Joomla Development
Saturday, August 6, 11                                                                            10
JObject
                         All Joomla classes derived from (You should too)

                         Easy getter/setter methods

                           $obj->set(‘var’, ‘value’); // Set a variable

                           $obj->get(‘var’, ‘default’); // Get a value

                           $obj->def(‘var’, ‘default’); // Set a default

                         $obj->toString(); // Great for debugging (no
                         print_r($obj) required!
 SourceCoast Extensions                   sourcecoast.com      Intro To Joomla Development
Saturday, August 6, 11                                                                   11
JUser Object
                         $user = JFactory::getUser(); // logged in user

                         $user = JUser::getInstance($id);

                         $id = UID or username

                         Once fetched, use

                           if ($user->guest)

                           $user->get('username'); // id, fullname,
                           lastvisitDate, etc

                              It’s derived from JObject!
 SourceCoast Extensions                   sourcecoast.com        Intro To Joomla Development
Saturday, August 6, 11                                                                     12
JFactory - Database
                         $dbo =& JFactory::getDBO() // Get the database handle

                         Functions described in JDatabase & JDatabaseMySQL(i)

                         $query = $dbo->getQuery(true); // New Query
                         $query->select(“id, username, email”);
                         $query->from(“#__users”);
                         $query->where(“username=”.$dbo->quote($username); // No
                         shenanigans!
                         $dbo->setQuery($query);

                         $dbo->setQuery(“SELECT id,username,email FROM #__users
                         WHERE username = “.$dbo->quote($username)); // Not as flexible

                         $user = $dbo->loadObject(); // objectList, array, arrayList, result, etc

                         Can use InsertObject function (or raw SQL) to add rows to database

 SourceCoast Extensions                         sourcecoast.com              Intro To Joomla Development
Saturday, August 6, 11                                                                                 13
URL Routing
                         JRoute

                           JRoute::_('index.php?
                           option=com_content&view=article&id=12');

                           Will determine correct SEF URL, if SEF is enabled

                           Also, SEF components (sh404, Artio, etc) override this call, so
                           it works for them too!

                         JURI

                           $uri = JFactory::getURI(); // Get current query string

                           $uri->setVar('view', 'blah'); // Add/change value

                           JRoute::_('index.php?'.$uri->getQuery()); // Create new route

 SourceCoast Extensions                      sourcecoast.com            Intro To Joomla Development
Saturday, August 6, 11                                                                            14
JApplication
                         Handle to the Application class

                         $app =& JFactory::getApplication();

                         $app->enqueueMessage('blah', 'error');

                         $app->redirect($url); // Use JRoute!

                         $app->isAdmin()

                         $app->isSite()

                         Formerly global $mainframe. Globals are bad..
 SourceCoast Extensions                   sourcecoast.com   Intro To Joomla Development
Saturday, August 6, 11                                                                15
JText
                         Text translation from language files

                         JText::_('COM_JFBCONNECT_LOGIN_MESSAGE’);

                         Searches loaded language files in last loaded order

                         Searches for first, exact, upper case version

                           If found, use translation; If not, use text directly

                         To include more language files:

                           $lang = JFactory::getLanguage(); // Get language object

                           $lang->load('com_jfbconnect'); // Add your file
 SourceCoast Extensions                     sourcecoast.com           Intro To Joomla Development
Saturday, August 6, 11                                                                          16
JRequest
                         JRequest::getVar('name', 'default', 'POST');

                         Can be risky depending on use. Preferred to
                         use the below 'sanitized' methods

                         JRequest::getInt('name', 4); // Integers only,
                         default 4

                         JRequest::getCmd('task'); // strip ./

                         JRequest::getString('name'); // No nasty
                         HTML
 SourceCoast Extensions                  sourcecoast.com     Intro To Joomla Development
Saturday, August 6, 11                                                                 17
JFilterInput
                         Clean data before using in code

                         Used to prevent SQL, XSS, and other
                         shenanigans or exploits

                         $filter =& JFilterInput::getInstance();

                         $filter->clean($var, ‘string’); //int, etc

                         Similar to (and used by) JRequest, but can be
                         used on any data, not just environment
                         variables
 SourceCoast Extensions                   sourcecoast.com      Intro To Joomla Development
Saturday, August 6, 11                                                                   18
Jsession
                         Store information volatile information for user

                         Form information on validation failure

                         Information before a redirection (to login, etc)

                         $session = JSession::getInstance();

                         $session->set('city', $cityInput); // Set now

                         $city = $session->get('city', ''); // Get later

                         $session->clear('city');
 SourceCoast Extensions                    sourcecoast.com        Intro To Joomla Development
Saturday, August 6, 11                                                                      19
Component
                         Structure


 SourceCoast Extensions    sourcecoast.com   Intro To Joomla Development
Saturday, August 6, 11                                                 20
Component
                                   Structure
                         True MVC(t) structure

                         <component_name>.php – entry-point. Determines
                         controller and calls task on it

                         controller.php – Sets up the model(s) and other data
                         structures to be used

                         /models/<model>.php – Data interface

                         /viewname/view.html.php – Uses the models to fetch
                         and setup the data for the template

                         /viewname/tmpl/default.php (or any other template file)
 SourceCoast Extensions                   sourcecoast.com        Intro To Joomla Development
Saturday, August 6, 11                                                                     21
Component Entry Point



       * /components/com_blah/blah.php
       * Purpose: setup your component - defines, includes, etc
       * Initialize the right controller for the page
       * Start executing whatever is requested
       * (This) code expects query string “task” param to be set
       * If execute called with no param, “display” will be default
 SourceCoast Extensions       sourcecoast.com     Intro To Joomla Development
Saturday, August 6, 11                                                      22
Component
                          Controllers
       Fetch model(s) for data manipulation/checks
         * $model = $this->getModel('mymodel')
         * Verify something from the model to proceed or cause a
         redirect
         * Ex. Load article, check if published, if not, redirect
       Instantiate the View
       * $view = $this->getView(‘viewName’, ‘html’);
       * Hand any data (model) to it for use
        * $view->setModel($model);
        * $view->assignRef(‘var’, $data); // var for the template
       * Tell the View to do it’s thing
        * $view->setLayout(‘templateName’);
        * $view->display();
 SourceCoast Extensions      sourcecoast.com    Intro To Joomla Development
Saturday, August 6, 11                                                    23
Controller
      (Fake) Content Example



                         Get article
                         Check if published
                         Load the view and prepare the template
                         By default, view of same name as controller will be called
                           Otherwise, use $view code from previous slide
 SourceCoast Extensions                       sourcecoast.com        Intro To Joomla Development
Saturday, August 6, 11                                                                         24
Component Model
                         The model is your database interface

                         Extends JModel

                         Has SQL queries for read or write

                         Model allows you to retrieve and manipulate
                         data simulating higher level database functions

                           Table class available for row-based read/writes

                         $this->_db is pre-set as database object
 SourceCoast Extensions                  sourcecoast.com     Intro To Joomla Development
Saturday, August 6, 11                                                                 25
Component View

                         Fetch the data needed from Model

                         Set data for template file

                           $this->assignRef('varName', $var);

                         Call the template to load



 SourceCoast Extensions                 sourcecoast.com     Intro To Joomla Development
Saturday, August 6, 11                                                                26
Component Template
                         Little/no code other than echo's

                         Should use only variables set from View

                         <?php echo $this->varName ?>

                         If followed, template overrides become simple

                           If not, life becomes a nightmare for your
                           clients

 SourceCoast Extensions                 sourcecoast.com     Intro To Joomla Development
Saturday, August 6, 11                                                                27
Plugins
                         JDocument
                            JLog
                           JForm
                           Oh My!
 SourceCoast Extensions    sourcecoast.com   Intro To Joomla Development
Saturday, August 6, 11                                                 28

Contenu connexe

En vedette

Toscana Joomla Party - Proteggiamo il nostro sito Joomla!
Toscana Joomla Party - Proteggiamo il  nostro sito Joomla!Toscana Joomla Party - Proteggiamo il  nostro sito Joomla!
Toscana Joomla Party - Proteggiamo il nostro sito Joomla!Paolo Nuti
 
Teaching Joomla the Right Way
Teaching Joomla the Right WayTeaching Joomla the Right Way
Teaching Joomla the Right Waybrian teeman
 
Template Layout Overrides - a beginner's guide
Template Layout Overrides - a beginner's guideTemplate Layout Overrides - a beginner's guide
Template Layout Overrides - a beginner's guideRuth Cheesley
 
Joomla Frameworks Kung Fu
Joomla Frameworks Kung FuJoomla Frameworks Kung Fu
Joomla Frameworks Kung FuOleg Nesterov
 
Joomla development
Joomla developmentJoomla development
Joomla developmentAnurag Gupta
 
Joomla Extensions Kung Fu
Joomla Extensions Kung FuJoomla Extensions Kung Fu
Joomla Extensions Kung FuOleg Nesterov
 

En vedette (6)

Toscana Joomla Party - Proteggiamo il nostro sito Joomla!
Toscana Joomla Party - Proteggiamo il  nostro sito Joomla!Toscana Joomla Party - Proteggiamo il  nostro sito Joomla!
Toscana Joomla Party - Proteggiamo il nostro sito Joomla!
 
Teaching Joomla the Right Way
Teaching Joomla the Right WayTeaching Joomla the Right Way
Teaching Joomla the Right Way
 
Template Layout Overrides - a beginner's guide
Template Layout Overrides - a beginner's guideTemplate Layout Overrides - a beginner's guide
Template Layout Overrides - a beginner's guide
 
Joomla Frameworks Kung Fu
Joomla Frameworks Kung FuJoomla Frameworks Kung Fu
Joomla Frameworks Kung Fu
 
Joomla development
Joomla developmentJoomla development
Joomla development
 
Joomla Extensions Kung Fu
Joomla Extensions Kung FuJoomla Extensions Kung Fu
Joomla Extensions Kung Fu
 

Similaire à Intro to Joomla Development

Joomla Day Austin Part 4
Joomla Day Austin Part 4Joomla Day Austin Part 4
Joomla Day Austin Part 4Kyle Ledbetter
 
Jquery Plugin
Jquery PluginJquery Plugin
Jquery PluginRavi Mone
 
Frozen Rails Slides
Frozen Rails SlidesFrozen Rails Slides
Frozen Rails Slidescarllerche
 
Webpack: your final module bundler
Webpack: your final module bundlerWebpack: your final module bundler
Webpack: your final module bundlerAndrea Giannantonio
 
Take control. write a plugin. part II
Take control. write a plugin. part IITake control. write a plugin. part II
Take control. write a plugin. part IIBaruch Sadogursky
 
Philly Spring UG Roo Overview
Philly Spring UG Roo OverviewPhilly Spring UG Roo Overview
Philly Spring UG Roo Overviewkrimple
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
JavaScript Coding with Class
JavaScript Coding with ClassJavaScript Coding with Class
JavaScript Coding with Classdavidwalsh83
 
Starting with jQuery
Starting with jQueryStarting with jQuery
Starting with jQueryAnil Kumar
 
What is the Joomla Framework and why do we need it?
What is the Joomla Framework and why do we need it?What is the Joomla Framework and why do we need it?
What is the Joomla Framework and why do we need it?Rouven Weßling
 
Nashville Symfony Functional Testing
Nashville Symfony Functional TestingNashville Symfony Functional Testing
Nashville Symfony Functional TestingBrent Shaffer
 
Content construction with zoo
Content construction with zooContent construction with zoo
Content construction with zooChris Rault
 
How To Build A Personal Portal On Google App Engine With Django
How To Build A Personal Portal On Google App Engine With DjangoHow To Build A Personal Portal On Google App Engine With Django
How To Build A Personal Portal On Google App Engine With DjangoJimmy Lu
 
The Solar Framework for PHP
The Solar Framework for PHPThe Solar Framework for PHP
The Solar Framework for PHPConFoo
 
jQuery Tips Tricks Trivia
jQuery Tips Tricks TriviajQuery Tips Tricks Trivia
jQuery Tips Tricks TriviaCognizant
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Ondřej Machulda
 

Similaire à Intro to Joomla Development (20)

Joomla Day Austin Part 4
Joomla Day Austin Part 4Joomla Day Austin Part 4
Joomla Day Austin Part 4
 
Jquery Plugin
Jquery PluginJquery Plugin
Jquery Plugin
 
Frozen Rails Slides
Frozen Rails SlidesFrozen Rails Slides
Frozen Rails Slides
 
Webpack: your final module bundler
Webpack: your final module bundlerWebpack: your final module bundler
Webpack: your final module bundler
 
Take control. write a plugin. part II
Take control. write a plugin. part IITake control. write a plugin. part II
Take control. write a plugin. part II
 
Philly Spring UG Roo Overview
Philly Spring UG Roo OverviewPhilly Spring UG Roo Overview
Philly Spring UG Roo Overview
 
Rails 101
Rails 101Rails 101
Rails 101
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
JavaScript Coding with Class
JavaScript Coding with ClassJavaScript Coding with Class
JavaScript Coding with Class
 
Starting with jQuery
Starting with jQueryStarting with jQuery
Starting with jQuery
 
Play framework
Play frameworkPlay framework
Play framework
 
Jquery
JqueryJquery
Jquery
 
What is the Joomla Framework and why do we need it?
What is the Joomla Framework and why do we need it?What is the Joomla Framework and why do we need it?
What is the Joomla Framework and why do we need it?
 
Nashville Symfony Functional Testing
Nashville Symfony Functional TestingNashville Symfony Functional Testing
Nashville Symfony Functional Testing
 
Content construction with zoo
Content construction with zooContent construction with zoo
Content construction with zoo
 
How To Build A Personal Portal On Google App Engine With Django
How To Build A Personal Portal On Google App Engine With DjangoHow To Build A Personal Portal On Google App Engine With Django
How To Build A Personal Portal On Google App Engine With Django
 
The Solar Framework for PHP
The Solar Framework for PHPThe Solar Framework for PHP
The Solar Framework for PHP
 
Advance jquery-plugin
Advance jquery-pluginAdvance jquery-plugin
Advance jquery-plugin
 
jQuery Tips Tricks Trivia
jQuery Tips Tricks TriviajQuery Tips Tricks Trivia
jQuery Tips Tricks Trivia
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
 

Dernier

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Dernier (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Intro to Joomla Development

  • 1. Joomla Development I t ’ s E a s i e r T h a n Y o u T h i n k SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 1
  • 2. SourceCoast A l e x A n d r e a e O w n e r / D e v e l o p e r JFBConnect Full Facebook Integration Suite for Joomla * Facebook Authentication * Facebook Page Tab / Canvas Support * Like, Comment, Fanbox, Recommendations & more widgets * Customizeable Profile Import Into * JomSocial, Community Builder, Kunena, K2, Agora * Lots more... Over 60 straight 5-star reviews on the JED SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 2
  • 3. Overview Module Structure API Overview Component Structure SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 3
  • 4. Joomla - MVC MVC(t) – Model View Controller (template) Controller – Sets up environment for the display Model – Data interface Generally to the database, but can 'create' data if necessary View – Uses the model to get data to display Template – Override-able display output SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 4
  • 5. Modules Linear code execution VC(t) (no real model necessary) Uses a 'helper.php' file for additional function calls Can be model-like, but modules don’t have DB tables Files: mod_<modulename>.php and .xml helpers/helper.php tmpl/default.php SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 5
  • 6. Modules - Basics mod_demo.xml mod_demo.php default.php SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 6
  • 7. Module Helper Files mod_demo.php helper.php * Separate out Classes/Functions default.php SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 7
  • 8. Modules/Component mod_demo.php Interaction * Load Component’s model * Re-Use Code! helper.php default.php SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 8
  • 9. Joomla API Overview SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 9
  • 10. Joomla API http://api.joomla.com Recently updated to Joomla 1.7 API - YAY! Left side, select “Joomla-Platform” package Bookmark, cuddle up to, and learn to love this page “Classes” describes JFactory – Most widely used JRoute – Get URL for specific component/view/task “Application” describes Every other Joomla function (many inherited into JFactory) SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 10
  • 11. JObject All Joomla classes derived from (You should too) Easy getter/setter methods $obj->set(‘var’, ‘value’); // Set a variable $obj->get(‘var’, ‘default’); // Get a value $obj->def(‘var’, ‘default’); // Set a default $obj->toString(); // Great for debugging (no print_r($obj) required! SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 11
  • 12. JUser Object $user = JFactory::getUser(); // logged in user $user = JUser::getInstance($id); $id = UID or username Once fetched, use if ($user->guest) $user->get('username'); // id, fullname, lastvisitDate, etc It’s derived from JObject! SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 12
  • 13. JFactory - Database $dbo =& JFactory::getDBO() // Get the database handle Functions described in JDatabase & JDatabaseMySQL(i) $query = $dbo->getQuery(true); // New Query $query->select(“id, username, email”); $query->from(“#__users”); $query->where(“username=”.$dbo->quote($username); // No shenanigans! $dbo->setQuery($query); $dbo->setQuery(“SELECT id,username,email FROM #__users WHERE username = “.$dbo->quote($username)); // Not as flexible $user = $dbo->loadObject(); // objectList, array, arrayList, result, etc Can use InsertObject function (or raw SQL) to add rows to database SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 13
  • 14. URL Routing JRoute JRoute::_('index.php? option=com_content&view=article&id=12'); Will determine correct SEF URL, if SEF is enabled Also, SEF components (sh404, Artio, etc) override this call, so it works for them too! JURI $uri = JFactory::getURI(); // Get current query string $uri->setVar('view', 'blah'); // Add/change value JRoute::_('index.php?'.$uri->getQuery()); // Create new route SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 14
  • 15. JApplication Handle to the Application class $app =& JFactory::getApplication(); $app->enqueueMessage('blah', 'error'); $app->redirect($url); // Use JRoute! $app->isAdmin() $app->isSite() Formerly global $mainframe. Globals are bad.. SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 15
  • 16. JText Text translation from language files JText::_('COM_JFBCONNECT_LOGIN_MESSAGE’); Searches loaded language files in last loaded order Searches for first, exact, upper case version If found, use translation; If not, use text directly To include more language files: $lang = JFactory::getLanguage(); // Get language object $lang->load('com_jfbconnect'); // Add your file SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 16
  • 17. JRequest JRequest::getVar('name', 'default', 'POST'); Can be risky depending on use. Preferred to use the below 'sanitized' methods JRequest::getInt('name', 4); // Integers only, default 4 JRequest::getCmd('task'); // strip ./ JRequest::getString('name'); // No nasty HTML SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 17
  • 18. JFilterInput Clean data before using in code Used to prevent SQL, XSS, and other shenanigans or exploits $filter =& JFilterInput::getInstance(); $filter->clean($var, ‘string’); //int, etc Similar to (and used by) JRequest, but can be used on any data, not just environment variables SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 18
  • 19. Jsession Store information volatile information for user Form information on validation failure Information before a redirection (to login, etc) $session = JSession::getInstance(); $session->set('city', $cityInput); // Set now $city = $session->get('city', ''); // Get later $session->clear('city'); SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 19
  • 20. Component Structure SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 20
  • 21. Component Structure True MVC(t) structure <component_name>.php – entry-point. Determines controller and calls task on it controller.php – Sets up the model(s) and other data structures to be used /models/<model>.php – Data interface /viewname/view.html.php – Uses the models to fetch and setup the data for the template /viewname/tmpl/default.php (or any other template file) SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 21
  • 22. Component Entry Point * /components/com_blah/blah.php * Purpose: setup your component - defines, includes, etc * Initialize the right controller for the page * Start executing whatever is requested * (This) code expects query string “task” param to be set * If execute called with no param, “display” will be default SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 22
  • 23. Component Controllers Fetch model(s) for data manipulation/checks * $model = $this->getModel('mymodel') * Verify something from the model to proceed or cause a redirect * Ex. Load article, check if published, if not, redirect Instantiate the View * $view = $this->getView(‘viewName’, ‘html’); * Hand any data (model) to it for use * $view->setModel($model); * $view->assignRef(‘var’, $data); // var for the template * Tell the View to do it’s thing * $view->setLayout(‘templateName’); * $view->display(); SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 23
  • 24. Controller (Fake) Content Example Get article Check if published Load the view and prepare the template By default, view of same name as controller will be called Otherwise, use $view code from previous slide SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 24
  • 25. Component Model The model is your database interface Extends JModel Has SQL queries for read or write Model allows you to retrieve and manipulate data simulating higher level database functions Table class available for row-based read/writes $this->_db is pre-set as database object SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 25
  • 26. Component View Fetch the data needed from Model Set data for template file $this->assignRef('varName', $var); Call the template to load SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 26
  • 27. Component Template Little/no code other than echo's Should use only variables set from View <?php echo $this->varName ?> If followed, template overrides become simple If not, life becomes a nightmare for your clients SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 27
  • 28. Plugins JDocument JLog JForm Oh My! SourceCoast Extensions sourcecoast.com Intro To Joomla Development Saturday, August 6, 11 28