How to Create Joomla 4.x Component
This is step-by-step guide on how to create a Joomla! 4 Model-View-Controller (MVC) component from scratch. Joomla! components are split into two main parts: administrator part and site part.
The administrator part provides an interface to manage the component, and the site part provides the pages requested by users visiting the website.
In this tutorial, we will be creating Joomla! component - com_planets.
The main directory of the component will be com_planets. The "com" prefix means "component" and the "planets" is the name of the component. Inside this directory, there are two sub-folders for the admin part and site part.
Create two sub-folders site and admin. You also need a manifest file - planets.xml. Keep changing this manifest file as you develop your extension and add more files and features.
Add the following basic files:
- planets.xml: XML manifest file that tells Joomla! how to install the component.
- admin/services/provider.php: It tells Joomla! how to initialize the component.
- admin/src/Controller/DisplayController.php: The MVC default Controller for the "Planets" page.
- admin/src/View/Planets/HtmlView.php: The MVC View for the "Planets" page.
- admin/tmpl/planets/default.php: The HTML and PHP template for the "Planets" page.
- Adding Basic Files
- Manifest Files for Extensions
- Types of Models in Joomla
- Admin Model
- Backend Toolbar and Actions; Controllers
- Creating and Managing Joomla Database Tables
- SQL Queries
B. Back-end: Controllers, Views and Models
- Page Title and Toolbar
- Sorting and Ordering
- Searching and Filtering
- Sub menu
- Back-end Actions: Delete, Publish and Unpublish
- Back-end Actions: New and Edit
- Custom Back-end Actions
C. Front-end or Site Part
- Entry Point File
- Main Controller File
- Site Model
- Variable request in menu type
- How to Access Menu Parameters
- List of Categories
- List of Items
- Single Item
- Front End Form
- Title for Front-end Views
D. Advanced Component Development
- How to Use User State Variables
- Link with Joomla Categories Component
- Add Configuration Options and Parameters
- Access Menu Parameters for Component
- Add Alias Field to Joomla Component
- Create Router for Component
- Add Access Control List (ACL) in Joomla
- Working with Images in Component
- Add Modal to Joomla Component
- Add Ordering of Items
- Add Update Server to Component
- Link with Joomla Custom Fields