With your favorite file manager and editor create two files called ''admin/sql/install.mysql.utf8.sql'' and ''admin/sql/updates/mysql/0.0.6.sql''. They should both have the same content, as follows:

<span id="admin/sql/install.mysql.utf8.sql">

<span id="admin/sql/install.mysql.utf8.sql">

Line 29:

Line 27:

</span>

</span>

−

This is the install file. It will be executed if your put an appropriate order in the ''helloworld.xml'' file

+

The file ''install.mysql.utf8.sql'' will be executed when you install this component. The file ''0.0.6.sql'' is executed when you do an update.

+

+

'''Important Note:''' When the component is installed, the files in the SQL updates folder (for example, ''admin/sql/updates/mysql'') are read and the name of the last file alphabetically is used to populate the component's version number in the <code>#__schemas</code> table. This value must be in this table in order for the automatic update to execute the update SQL files for future versions. For this reason, it is good practice to create a SQL update file for each version (even if it is empty or just has a comment). This way the <code>#__schemas</code> version will always match the component version.

+

+

This is the install file. It will be executed if you put an appropriate order in the ''helloworld.xml'' file

<span id="helloworld.xml">

<span id="helloworld.xml">

Line 35:

Line 37:

<source lang="xml">

<source lang="xml">

<?xml version="1.0" encoding="utf-8"?>

<?xml version="1.0" encoding="utf-8"?>

−

<extension type="component" version="1.6.0" method="upgrade">

+

<extension type="component" version="2.5.0" method="upgrade">

<name>Hello World!</name>

<name>Hello World!</name>

−

<!-- The following elements are optional and free of formatting conttraints -->

+

<!-- The following elements are optional and free of formatting constraints -->

<creationDate>November 2009</creationDate>

<creationDate>November 2009</creationDate>

<author>John Doe</author>

<author>John Doe</author>

Line 60:

Line 62:

</sql>

</sql>

</uninstall>

</uninstall>

−

<update> <!-- Runs on update; New in 1.6 -->

+

<update> <!-- Runs on update; New in 2.5 -->

<schemas>

<schemas>

<schemapath type="mysql">sql/updates/mysql</schemapath>

<schemapath type="mysql">sql/updates/mysql</schemapath>

Line 114:

Line 116:

== Adding a new field type ==

== Adding a new field type ==

−

For the moment, we have used a [[Developing_a_Model-View-Controller_%28MVC%29_Component_for_Joomla!1.6_-_Part_03|hard coded field type for messages]]. We need to use our database for choosing the message.

+

For the moment, we have used a [[Developing_a_Model-View-Controller_%28MVC%29_Component_for_Joomla!2.5_-_Part_03|hard coded field type for messages]]. We need to use our database for choosing the message.

Modify the ''site/views/helloworld/tmpl/default.xml'' file and put these lines

Modify the ''site/views/helloworld/tmpl/default.xml'' file and put these lines

Create a compressed file of this directory or directly download the [http://joomlacode.org/gf/download/frsrelease/11394/58396/com_helloworld-1.6-part06.zip archive] and install it using the extension manager of Joomla!1.6. You can add a menu item of this component using the menu manager in the backend.

+

Create a compressed file of this directory or directly download the [http://joomlacode.org/gf/download/frsrelease/11394/58405/com_helloworld-1.6-part06.zip archive] and install it using the extension manager of Joomla. You can add a menu item of this component using the menu manager in the backend.

+

+

Note: site/models/helloworld.php is not up-to-date as mentioned on this page. You need to copy the code yourself.

== Navigate ==

== Navigate ==

−

[[Developing a Model-View-Controller (MVC) Component for Joomla!1.6 - Part 05|Prev: Adding a variable request in the menu type]]

+

[[Developing a Model-View-Controller (MVC) Component for Joomla!2.5 - Part 05|Prev: Adding a variable request in the menu type]]

The file install.mysql.utf8.sql will be executed when you install this component. The file 0.0.6.sql is executed when you do an update.

Important Note: When the component is installed, the files in the SQL updates folder (for example, admin/sql/updates/mysql) are read and the name of the last file alphabetically is used to populate the component's version number in the #__schemas table. This value must be in this table in order for the automatic update to execute the update SQL files for future versions. For this reason, it is good practice to create a SQL update file for each version (even if it is empty or just has a comment). This way the #__schemas version will always match the component version.

This is the install file. It will be executed if you put an appropriate order in the helloworld.xml file

helloworld.xml

<?xmlversion="1.0"encoding="utf-8"?><extensiontype="component"version="2.5.0"method="upgrade"><name>Hello World!</name><!-- The following elements are optional and free of formatting constraints --><creationDate>November 2009</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 recorded in the components table --><version>0.0.6</version><!-- The description is optional and defaults to the name --><description>Description of the Hello World component ...</description><install><!-- Runs on install --><sql><filedriver="mysql"charset="utf8">sql/install.mysql.utf8.sql</file></sql></install><uninstall><!-- Runs on uninstall --><sql><filedriver="mysql"charset="utf8">sql/uninstall.mysql.utf8.sql</file></sql></uninstall><update><!-- Runs on update; New in 2.5 --><schemas><schemapathtype="mysql">sql/updates/mysql</schemapath></schemas></update><!-- Site Main File Copy Section --><!-- 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 --><filesfolder="site"><filename>index.html</filename><filename>helloworld.php</filename><filename>controller.php</filename><folder>views</folder><folder>models</folder></files><administration><!-- Administration Menu Section --><menu>Hello World!</menu><!-- Administration Main File Copy Section --><!-- 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 --><filesfolder="admin"><!-- Admin Main File Copy Section --><filename>index.html</filename><filename>helloworld.php</filename><!-- SQL files section --><folder>sql</folder><!-- tables files section --><folder>tables</folder><!-- models files section --><folder>models</folder></files></administration></extension>

The new field type displays a drop-down list of messages to choose from. You can see the result of this change in the menu manager section for the helloworld item.

Display the chosen message

When a menu item of this component is created/updated, Joomla stores the identifier of the message. The HelloWorldModelHelloWorld model has now to compute the message according to this identifier and the data stored in the database.

Create a compressed file of this directory or directly download the archive and install it using the extension manager of Joomla. You can add a menu item of this component using the menu manager in the backend.

Note: site/models/helloworld.php is not up-to-date as mentioned on this page. You need to copy the code yourself.