Understanding what a Joomla! component is
In Joomla!, we have several types of extensions – components, modules, plugins, templates, libraries, packages, and languages. All of these have a specific purpose in the system, but due to Joomla’s flexibility, in some cases, it can get difficult to choose one type over the other. Should I use a module to include content at the end of my articles, or is it better to use a content plugin? Do I use a custom user plugin to add fields to my user profile, or should I use Joomla! Custom Fields capabilities? After reading this book, you will be able to choose the option that best fits your project.
The main and most complete extensions in Joomla! are components. We can think of Joomla! components as small web applications on their own. Components do not need to be supported by any other parts of your Joomla! site. They can work isolated from the rest of your site, and they complete the scope of your website.
In any case, you will get the most from any component when they team up with other Joomla! parts, such as modules or plugins.
Your website is formed by lots of pages, and every page has a URL. In Joomla!, every time you access a URL, you are inside a Joomla! component. So, components have their own page requests, and no other components of the site can affect them when you load their URL. Despite this isolation, they can communicate with other components using their code.
Some characteristics of a Joomla! component are as follows:
- Joomla! components offer a secure entry point for your requests. With them, you may create webhooks for external services or receive data from forms.
- Components usually have a backend and a frontend. The backend is usually restricted to managers and administrators of the site and is used to manage the data.
- In most scenarios, your component will have to store data in the database. For instance, if you want to create a component to track your projects’ progress, you need to store the names of your projects, their statuses, and probably more information in the database. For this reason, components install new tables in your database to store information.
- Components automatically add themselves to Joomla’s backend menu, and they install new menu item types on your site to show their data on the site’s frontend.
In fact, in Joomla!, you are always working with components as every page (backend or frontend) of your site is a component view.
Now that we know some characteristics of a component, let’s see how we can use them to solve real-world problems.