How to Invoke a Controller Function in a Joomla URL

When we develop custom Joomla components for our clients, a very common task that we do is that we call custom controller functions from a URL within a view. For example, just today, while working on a custom component that’ll allow people to post their press releases through the frontend of a Joomla website, we wanted to allow people to delete uploaded images from within a view. To do that, we added, next to each image, a link that will delete the image when someone clicks it.

The link looked like the following:

http://www.ourclientjoomlawebsite/index.php?option=com_pr&task=pr.delete_image&id=5

Now to explain the link, let us dissect it:

  • com_pr: This is the name of the component (for example, com_content).
  • pr.delete_image: This is actually a combination of the controller name and the function name to call joined by a dot (.) . For example, in our scenario, the controller name is pr, and the name of the function to call is delete_image.

  • 5: This is the id of the image to delete in our scenario. This id is passed to the function delete_image. You can have as many parameters as you want in the URL.

So, the delete_image function in the pr controller will get the id of the image from the GET and then deletes that image. Easy, huh?

So, if you are trying to call a function in your controller from a URL, this is the way to do it. If you’re still having challenges doing it, or if there’s something that you don’t understand, then why don’t you just let us do this task for you? Our work is professional, our prices are affordable, we are very friendly, and our clients really love us. Go ahead, contact us, you won’t regret it.

Note: We know, this is yet another short post. This is not a trend, we promise, but the thing is we are extremely busy these days and we definitely need more people on our team to serve our growing number of clients.

2 Responses to “How to Invoke a Controller Function in a Joomla URL”
  1. Comment by David Addoteye — September 30, 2016 @ 11:57 am

    Great! This post has saved practically 12 hours of my time! Thank you guys!

  2. Comment by Fadi — October 26, 2016 @ 4:21 pm

    Hi David,

    You’re welcome!

Leave a comment