---
title: "How to add a New Task to your Joomla 3 Component"
description: "This tutorial series, Joomla 3 component development, is currently in progress... So far in this tutorial series for creating a component in Joomla 3, we've created views and we've created formats...."
url: https://www.inmotionhosting.com/support/edu/joomla/joomla-3/add-new-task/
date: 2014-05-18
modified: 2023-06-07
author: "Brad Markle"
categories: ["Joomla", "Joomla 3"]
tags: ["Joomla v3"]
type: post
lang: en
---

# How to add a New Task to your Joomla 3 Component

This tutorial series, [Joomla 3 component development](https://www.inmotionhosting.com/support/edu/joomla/joomla-3/joomla-search-component/), is currently in progress…

So far in this tutorial series for creating a component in Joomla 3, we’ve created [views](https://www.inmotionhosting.com/support/edu/joomla/joomla-3/add-new-view/) and we’ve created [formats](https://www.inmotionhosting.com/support/edu/joomla/joomla-3/formats/). The next feature of components we’re going to review is tasks.

## What is a task?

A task is, well… something that can be done. The usage of “*tasks*” when developing components in Joomla is what it sounds like.

### display() is the default task

If you do not specify a task, the default task *display()* will be executed. The screenshot below demonstrates this in action. When we echo the **task** to the screen, it is blank (meaning it is not set). Because there is no task set, the **default()** task / function is then executed.

[![Default task execution](/support/images/stories/edu/joomla-3/create-component/display-is-default-task.png)](/support/images/stories/edu/joomla-3/create-component/display-is-default-task.png)

## How to add a new task

Adding a new task to your component is actually quite easy. Here are the steps.

1. **Decide on a task name**In our testing, we are going to create a task named *shout*.
2. **Add a function named after your task within your component’s controller class**Since we’re creating a *shout* task, we need to create a function named **shout()** and add it to our controller’s class. Below is our controller.php file, with the new code we added to it highlighted in red. <?php // No direct access to this file defined('_JEXEC') or die('Restricted access'); // import Joomla controller library [jimport](https://www.inmotionhosting.com/support/edu/joomla/joomla-3/jimport/)('joomla.application.component.controller'); /** * Hello World Component Controller */ class HelloWorldController extends JControllerLegacy { function **shout()** { echo "<p>THIS IS ME SHOUTING!</p>"; } }

## Testing your new task

We’re testing our new task by calling it in the URL. To do this, we’re passing the task variable via the URL and setting it to *shout*, as in:

https://example.com/index.php?option=com_helloworld&task=**shout**

In the screenshot below, you can see our new task in action:

[![New task execution](/support/images/stories/edu/joomla-3/create-component/executing-our-new-task.png)](/support/images/stories/edu/joomla-3/create-component/executing-our-new-task.png)
