InMotion Hosting Support Center

This tutorial series, Joomla 3 component development, is currently in progress...

In our last tutorial, we showed you how to create the default view for the component that we are creating. The component's name is com_helloworld, so the default view is helloworld - this is just how the "default view" works.

In this tutorial, we are going to show you how to add a new view. This new view we will call "Howdy Friends".

To create a new view:

  1. Create the view's folder: /components/helloworld/views/howdyfriends

    Because we are referring to this new view as "Howdy Friends", we will name this view howdyfriends.
  2. Create the HTML version of the view: /components/helloworld/views/howdyfriends/view.html.php

    // No direct access to this file
    defined('_JEXEC') or die('Restricted access');
    // import Joomla view library
     * HTML View class for the HowdyFriends view
    class HelloWorldViewHowdyFriends extends JViewLegacy
            // Overwriting JView display method
            function display($tpl = null)
                    // Assign data to the view
                    $this->msg = 'Howdy Friends, welcome to component development!';
                    // Display the view
  3. Create the "templates" folder: /components/helloworld/views/howdyfriends/tmpl
  4. Create the default template file: /components/helloworld/views/howdyfriends/tmpl/default.php
    // No direct access to this file
    defined('_JEXEC') or die('Restricted access');
    <h1><?php echo $this->msg; ?></h1>

How to test your new view

Now that the hard part is over, let's test our view! It can be accessed using the following url:

The URL above was created by defining the component we want to run - com_helloworld, and the component's view we want to run - howdyfriends.

If you're following along with our tutorial, when testing your new view, it should look similar to the image to the right:

Was this article helpful?
Continued Education in Course How to create a Joomla 3 Component
You are viewing Section 4: How to add a New View to your Joomla 3 Component
Section 3: How to add a Default View to your Joomla 3 Component
Section 5: How to add a New Format to your Joomla 3 Component

Joomla Community Google+ Hangout #3

June 3rd, 2014

Thank you @RustyJoomla for letting me speak on the Joomla Community Google+ Hangout!

Click here to watch!

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Support Center Login

Our Login page has moved, Click the button below to be taken to the login page.

n/a Points
2017-06-05 7:37 am

Thanks, guys! This explication helped me a lot!

n/a Points
2016-12-15 7:38 am

Shouldn't Create a New View>Step 2 be 

Create the HTML version of the view: /components/com_helloworld/views/howdyfriends/view.html.php

and not

Create the HTML version of the view: /components/helloworld/views/howdyfriends/view.html.php

n/a Points
2016-02-17 2:22 am

I have done same as mentioned above but it is not displaying text inside view.html.php instead it displays inside components/com_helloworld/helloworld.phpWhy this happening?

42,432 Points
2016-02-17 4:48 pm
Hello Ashwini,

If you have made the same changes as listed in the code above, then it should be working. If you're seeing something different, then it's possible you have mixed up a step. If you want us to verify, we would need to have access to the backend of your Joomla installation in order to look at the changes. Please double-check your files. If require further assistance, please provide us access or more information concerning the error.

If you have any further questions or comments, please let us know.

Arnel C.
n/a Points
2016-01-12 7:19 am

Hi there!Nice collection of tutorials, ive found some good stuff here for my own developmentJust 1 question:lets pretend that i have a very simple component and i need 3 views: a list, a simple form and a show. Do i have to create this structure for each view? maybe i'm missing something for switching between de default view to anotherThanks a lot for the answer!

10,806 Points
2016-01-12 12:24 pm
If you're asking if you need a separate structure for a form or list then no, you should be able to put in a form or list on any page without a dedicated structure. You do not need to create a separate structure for each one.

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

6 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!