Actions

User

Rvsjoen/tutorial/Developing an MVC Component/Part 03

From Joomla! Documentation

< User:Rvsjoen‎ | tutorial/Developing an MVC Component

Contents

Adding a menu item type to the frontend

In Joomla! components are executed using menu items. If you go into the menu manager of your Joomla! installation a HelloWorld menu item type does not yet exist. In order for our view to be selectable as a menu item type, we need to provide an XML manifest for that view.

With your favorite editor, create the following file

site/views/helloworld/tmpl/default.xml

<?xml version="1.0" encoding="utf-8"?>
<metadata>
        <layout title="Hello World">
                <message>Hello World menu item description</message>
        </layout>
</metadata>

Installation manifest

There are no changes to the installation manifest in this part except for the version number.

helloworld.xml

<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="2.5.0" method="upgrade">
 
        <name>Hello World!</name>
        <!-- The following elements are optional and free of formatting constraints -->
        <creationDate>June 2011</creationDate>
        <author>John Doe</author>
        <authorEmail>john.doe@example.org</authorEmail>
        <authorUrl>http://www.example.org</authorUrl>
        <copyright>Copyright Info</copyright>
        <license>License Info</license>
        <!--  The version string is stored in the components table -->
        <version>0.0.3</version>        <!-- The description is optional and defaults to the name -->
        <description>Description of the Hello World component ...</description>
 
        <!-- Note the folder attribute: This attribute describes the folder
                to copy FROM in the package to install therefore files copied
                in this section are copied from "site/" in the package -->
        <files folder="site">
                <filename>index.html</filename>
                <filename>helloworld.php</filename>
                <filename>controller.php</filename>
                <folder>views</folder>
        </files>
 
        <administration>
                <menu>Hello World!</menu>
                <!-- Note the folder attribute: This attribute describes the folder
                        to copy FROM in the package to install therefore files copied
                        in this section are copied from "admin/" in the package -->
                <files folder="admin">
                        <filename>index.html</filename>
                        <filename>helloworld.php</filename>
                </files>
        </administration>
 
</extension>

Testing your component

For details on how to install the component into your Joomla! site, refer to the information provided in Part 01.

In order to test this component, go to the administrator interface and create a new menu item. In the menu item type selection interface, pick Hello World as the menu item type. Now you should be able to access this menu item in the frontend and it should show you the same result as when you entered the url directly in the previous part.

File listing

Download this part

Download example package

Articles in this series

This tutorial is supported by the following versions of Joomla!

Joomla 2.5