Developing Extensions for Joomla! 5: Extend your sites and build rich customizations with Joomla! plugins, modules 9781804617991

Harness the full potential of Joomla! through this comprehensive take on Joomla! extensions from conception through to r

474 111 4MB

English Pages 322 Year 2023

Report DMCA / Copyright

DOWNLOAD FILE

Developing Extensions for Joomla! 5: Extend your sites and build rich customizations with Joomla! plugins, modules
 9781804617991

Table of contents :
Developing Extensions for Joomla! 5
Foreword
Contributors
About the author
About the reviewer
Preface
Who this book is for
What this book covers
To get the most out of this book
Disclaimer
Download the example code files
Conventions used
Get in touch
Share Your Thoughts
Download a free PDF copy of this book
Part 1: Developing Components
1
Planning Your Component
Understanding what a Joomla! component is
Translating your problem into an application
Identifying your elements
A real-world example
Defining your component database structure
A quick look at the Joomla! database
Adding database tables for entities
Adding extra information columns to tables
Reflecting relationships in the database
Creating tables in the database
Adding mock data to your database
Defining the content of our mock data
Automating mock data generation
Importing mock data into the database
Summary
Further reading
2
Developing the Backend of a Basic Joomla! Component
Technical requirements
Component file architecture
Building a component’s backend
Creating our component repository structure
Creating a manifest file
Testing a minimum component on Joomla!
Developing a list view for a component
Adding the view for projects data
Adding a model to the projects view
Showing the list of projects
Developing an edit item view for our component
Creating a Project view
Adding a model to retrieve and save data
Adding a controller to our Project entity
Creating a layout for our edit project view
Changes to our manifest file
Testing the component
Summary
Further reading
3
Developing the Frontend of a Basic Joomla! Component
Technical requirements
Developing a frontend list view for our component
Coding the list view
Adding CSS and JS to our component
Adding our own styles and JavaScript to our component
Joomla’s Web Asset Manager
Loading assets with HtmlHelper
Developing a frontend item view for our component
Adding the model for the frontend item view
Adding the layout for the item detail
Adding a menu item for our views
Adding friendly URLs to our component
Translating parameters into a friendly URL
Translating SEF URLs into variables for our component
Summary
Further reading
4
Creating Forms in Joomla!
Technical requirements
Defining forms in Joomla!
Adding general options to our extensions
Adding search and filter capabilities to our listings
Editing or adding individual items
Using standard Joomla! Form fields
Using the Editor form field type
Using the accessiblemedia field type
Creating select options from database tables
Defining custom form field types
How to use the subform field type
Validating user input on the client side
Validating user input on the server side
Summary
Further reading
5
Harnessing the Power of Joomla! in Your Component
Technical requirements
Reviewing what Joomla! features you can use in your component
Adding an ACL to our component
Setting up Joomla! user groups and viewing access levels
Adding the permissions configuration
Honoring the permissions in our extensions
Defining custom actions for our component
Using Joomla! categories in our component
Customizing our component categories
Exploring the benefits and limitations of using Joomla! categories
Using our categories’ custom properties
Adding ACL to our component categories
Introduction to Joomla! custom fields
Using custom fields in our component
Showing custom fields in our views
Adding an ACL to the custom fields
Using Joomla’s multilingual capabilities in our component
Adding complex translations
Summary
Further reading
6
Adding a Web Service API to Your Component
Technical requirements
What is a Web Service API?
How to consume any Web Service API
How can I use the Joomla! Web Service API?
Authorization for the API
Basic authorization
Joomla! token authorization
Web Services API permissions
Adding a Web Service API to your component
Developing the Web Service plugin
Using createCRUDRoutes() to add our Web Service endpoints
Adding custom endpoint requests to our Web Service
Handling the request in our component
Reading data from your Web Service – adding a GET endpoint to your component
Writing data from your Web Service – adding a POST endpoint to your component
Summary
Further reading
Part 2: Developing Modules and Plugins
7
Developing a Module
Technical requirements
Understanding the module file structure
Creating the provider code
Using module helpers
Adding the layout for the module
Writing the manifest for our module
Using module configuration parameters
Adding an Advanced tab to our module configuration
Caching Joomla! modules
Using saved parameters in your code
Summary
Further reading
8
Developing a Joomla! Plugin
Technical requirements
What is a plugin in Joomla!?
Calling Joomla! plugins from our component
Understanding Joomla’s plugin file structure
Creating the manifest file for our plugins
Creating a content plugin
Adding plugins to our component
Creating our customer’s plugin
Summary
Further reading
9
Adding a CLI to Your Extension
Technical requirements
What is a CLI?
What is a Cron Job?
How to use Joomla! CLI
Introducing Joomla! CLI commands
Introducing generic options for Joomla! CLI
Adding a Joomla! CLI command to Joomla!
Exploring SymfonyStyle methods
What Symfony console output tags can we use?
How to internationalize CLI messages
Adding parameters to your CLI command
Summary
Further reading
Part 3: Extending Templates
10
Creating Unique Web Applications with Template Overrides
Technical requirements
What is a Joomla! template?
What are template overrides?
Creating a template override for Joomla! views
Creating a template override for a component view
Creating a template override for a module
Creating a template override for a plugin
Creating alternative layouts
Adding an alternative menu item for a component view
Adding an alternative layout for a module
Overriding CSS and JS
Overriding assets with the Web Assets Manager
Adding new assets to our overrides
Disabling assets in our overrides
Summary
Further reading
11
Creating a Child Template in Joomla!
Technical requirements
Why do we need child templates?
Creating a child template
Creating a child template directly in our repository
Creating a child template using the Joomla! template manager
Overrides in child templates
Adding a new module position to the template
Using different styles for the module
Reusing child templates on different sites
Adding parameters to a child template
Adding language files to our child template
Summary
Further reading
Part 4: Distributing Your Extensions
12
Testing Your Extensions
Technical requirements
Do I need tests?
Including unit testing in Joomla!
What is TDD?
Installing PHPUnit
How to add system testing in Joomla!
Installing Codeception
Testing accessibility in our extensions
Testing accessibility with your browser
Summary
Further reading
13
Security Practices in Joomla!
Technical requirements
Fetching data from forms
Filtering input data before saving it to a database
Preventing cross-site request forgery (CSRF) attacks in forms
Preventing cross-site scripting (XSS) attacks
Preventing SQL injection
Securing your assets for the future
Hardening access to your files
Using the JED Checker extension
Summary
Further reading
14
Distributing Your Joomla! Extensions
Technical requirements
Creating a package for your extensions
Managing versions in your extension
Packaging all the extensions into one file
How to manage database changes on your extensions
How to change your database structure by updating your extensions
Cleaning the database on uninstall
How to execute advanced tasks on extension install
Setting up an update server
Adding a paywall to your extension download
Summary
Further reading
Index
Why subscribe?
Other Books You May Enjoy
Packt is searching for authors like you
Share Your Thoughts
Download a free PDF copy of this book

Polecaj historie