User

User:Rvsjoen/tutorial/Developing an MVC Component/Part 05

From Joomla! Documentation

Revision as of 09:18, 11 July 2011 by Rvsjoen (talk | contribs) (Created page with "= Adding options to menu items = With your favorite editor, modify the following file to look like this <span id="site/views/helloworld/tmpl/default.xml"> '''<tt>site/views/...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Adding options to menu items

With your favorite editor, modify the following file to look like this

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>
        <fields name="request">
                <fieldset name="request">
                        <field
                                name="id"
                                type="list"
                                label="Greeting"
                                description="Select a greeting"
                                default="1"
                        >
                                <option value="1">Hello World!</option>
                                <option value="2">Good bye World!</option>
                        </field>
                </fieldset>
        </fields>
</metadata>

Installation manifest

No changes have been made to the installation manifest apart from updating the version number.

helloworld.xml

<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="1.6.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.5</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>
                <folder>models</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. In the options of the menu item you will be able to choose which hello message to show, the message you choose should be displayed in the frontend as in the previous part.

File listing

Download this part

com_helloworld-part01.zip

Articles in this series

This tutorial is supported by the following versions of Joomla!

Joomla 2.5