Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Developing Extensions for Joomla! 5

You're reading from   Developing Extensions for Joomla! 5 Extend your sites and build rich customizations with Joomla! plugins, modules, and components

Arrow left icon
Product type Paperback
Published in Nov 2023
Publisher Packt
ISBN-13 9781804617991
Length 322 pages
Edition 1st Edition
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Carlos M. Cámara Mora Carlos M. Cámara Mora
Author Profile Icon Carlos M. Cámara Mora
Carlos M. Cámara Mora
Arrow right icon
View More author details
Toc

Table of Contents (21) Chapters Close

Preface 1. Part 1: Developing Components
2. Chapter 1: Planning Your Component FREE CHAPTER 3. Chapter 2: Developing the Backend of a Basic Joomla! Component 4. Chapter 3: Developing the Frontend of a Basic Joomla! Component 5. Chapter 4: Creating Forms in Joomla! 6. Chapter 5: Harnessing the Power of Joomla! in Your Component 7. Chapter 6: Adding a Web Service API to Your Component 8. Part 2: Developing Modules and Plugins
9. Chapter 7: Developing a Module 10. Chapter 8: Developing a Joomla! Plugin 11. Chapter 9: Adding a CLI to Your Extension 12. Part 3: Extending Templates
13. Chapter 10: Creating Unique Web Applications with Template Overrides 14. Chapter 11: Creating a Child Template in Joomla! 15. Part 4: Distributing Your Extensions
16. Chapter 12: Testing Your Extensions 17. Chapter 13: Security Practices in Joomla! 18. Chapter 14: Distributing Your Joomla! Extensions 19. Index 20. Other Books You May Enjoy

Adding friendly URLs to our component

Friendly URLs in web development are a two-sided problem. On the one hand, when showing a URL to your users, you need to translate all your ugly links with parameters into words to make them more friendly. These words usually match the name of the page we are showing, and we call them slugs or aliases. For example, in the https://YourDomain.com/joomla-4-extension-development URL, the slug is joomla-4-extension-development.

The second problem starts when your users request a friendly URL, and you need to translate it into parameters for your Joomla! site to understand the request.

To handle these problems in Joomla!, we need to add a so-called router to our component. In Joomla!, we inject the router as a service.

To do this, edit the src/component/admin/services/provider.php file and add the following namespaces:

src/component/admin/services/provider.php

use Joomla\CMS\Extension\Service\Provider\RouterFactory;
use Joomla\CMS\Component...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime