<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Over</id>
	<title>Joomla! Documentation - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Over"/>
	<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/Special:Contributions/Over"/>
	<updated>2026-08-20T06:36:32Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_A_form_and_ajax&amp;diff=125343</id>
		<title>User:Over/Step by step to a Joomla Module - A form and ajax</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_A_form_and_ajax&amp;diff=125343"/>
		<updated>2014-09-10T16:22:06Z</updated>

		<summary type="html">&lt;p&gt;Over: /* mod_yourmodule.php Use a model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{underconstruction}}&lt;br /&gt;
&lt;br /&gt;
{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this part of the tutorial we will use the form functionality of Joomla!. In a second step we&#039;ll add the Joomla! Ajax functionality to the module. If you want to keep the custom module you created up till now, you should use the knowledge you&#039;ve got from this tutorial and fork it. i.e. you copy all the files to a new local folder and change all filenames to a new name. Then you change all texts in the files including the old module name to a new at your choise, create an installation file and install the new module. We will still use yourmodule as name, so you&#039;ll have to adopt your own as before.&lt;br /&gt;
&lt;br /&gt;
Ajax = short for asynchronous JavaScript + XML&lt;br /&gt;
{{Tip|We will not mention the name adoption anymore and be less specific about file update.}}&lt;br /&gt;
&lt;br /&gt;
If you have a MVC component related to your module, it&#039;s easier and recommended to include the form functionality a.k.a. JForm by using the components methods. We&#039;ll add it without a component in this example.&lt;br /&gt;
&lt;br /&gt;
Why use JForm for html forms? You get a lot for &amp;quot;free&amp;quot;, like fields html code, client and server side validation.&lt;br /&gt;
&lt;br /&gt;
We first need a xml form declaration. In the folder where you unzipped the downloaded file you can find a models folder. Copy this to your modules web &#039;root&#039; folder. A module doesn&#039;t follow the MVC pattern, but let us use models as folder name. For a component you&#039;ll find forms, fields and rules in this path. You can find examples of custom fields and rules in those folders.&lt;br /&gt;
&lt;br /&gt;
=== The form ===&lt;br /&gt;
Open models/forms/yourmodule_form.xml for edit.&lt;br /&gt;
&lt;br /&gt;
==== message.xml ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;form&amp;gt;&lt;br /&gt;
   &amp;lt;fieldset addfieldpath=&amp;quot;modules/mod_yourmodule/models/fields&amp;quot;&lt;br /&gt;
             addrulepath=&amp;quot;modules/mod_yourmodule/models/rules&amp;quot;&amp;gt;  &lt;br /&gt;
      &amp;lt;field name=&amp;quot;subject&amp;quot;&lt;br /&gt;
         type=&amp;quot;text&amp;quot;&lt;br /&gt;
         size=&amp;quot;60&amp;quot;&lt;br /&gt;
         description=&amp;quot;MOD_YOURMODULE_MESSAGE_SUBJECT_DESC&amp;quot;&lt;br /&gt;
         label=&amp;quot;MOD_YOURMODULE_MESSAGE_SUBJECT_LABEL&amp;quot;&lt;br /&gt;
         filter=&amp;quot;string&amp;quot;&lt;br /&gt;
         validate=&amp;quot;yourmessagesubject&amp;quot;&lt;br /&gt;
         required=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;field name=&amp;quot;message&amp;quot;&lt;br /&gt;
         type=&amp;quot;textarea&amp;quot;&lt;br /&gt;
         cols=&amp;quot;50&amp;quot;&lt;br /&gt;
         rows=&amp;quot;10&amp;quot;&lt;br /&gt;
         description=&amp;quot;MOD_YOURMODULE_ENTER_MESSAGE_DESC&amp;quot;&lt;br /&gt;
         label=&amp;quot;MOD_YOURMODULE_ENTER_MESSAGE_LABEL&amp;quot;&lt;br /&gt;
         filter=&amp;quot;safehtml&amp;quot;&lt;br /&gt;
         validate=&amp;quot;yourmessage&amp;quot;&lt;br /&gt;
         required=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To be able to use our own fields and rules we add &#039;addfieldpath&#039; and &#039;addrulepath&#039;. Explaning the details of the declarations is outside the scope of this tutorial. Only so far: we add two fields &#039;subject&#039; and &#039;message&#039;. As you can see we use the same xml pattern as is used for the module options. Change the labels and descriptions. Do &#039;&#039;&#039;NOT&#039;&#039;&#039; change &#039;your&#039; in the validate lines or you have to edit the rules files. &lt;br /&gt;
&lt;br /&gt;
More about [[Form_field|Form fields]]&lt;br /&gt;
&lt;br /&gt;
You can find examples of form declarations in the core components. e,g. /administrator/com_content/models/forms/article.xml&lt;br /&gt;
&lt;br /&gt;
=== The language strings ===&lt;br /&gt;
&lt;br /&gt;
We have to add the language strings to the .ini file&lt;br /&gt;
&lt;br /&gt;
==== en-GB.mod_yourmodule.ini Form texts ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_MESSAGE_SUBJECT_DESC=&amp;quot;The subject of yor message&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_MESSAGE_SUBJECT_LABEL=&amp;quot;Subject&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_ENTER_MESSAGE_DESC=&amp;quot;Add your message&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_ENTER_MESSAGE_LABEL=&amp;quot;Message&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add the form to the output ===&lt;br /&gt;
&lt;br /&gt;
==== default.php With a form ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;A form your module&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;form id=&amp;quot;mod_yourmodule_&amp;lt;?php echo $module-&amp;gt;id;?&amp;gt;&amp;quot; action=&amp;quot;&amp;lt;?php echo JRoute::_(&#039;index.php&#039;); ?&amp;gt;&amp;quot; method=&amp;quot;post&amp;quot; class=&amp;quot;form-validate&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;fieldset class=&amp;quot;well&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;?php&lt;br /&gt;
      echo $form-&amp;gt;renderField(&#039;subject&#039;);&lt;br /&gt;
      echo $form-&amp;gt;renderField(&#039;message&#039;);&lt;br /&gt;
&lt;br /&gt;
   if (!$messageSent)&lt;br /&gt;
   {&lt;br /&gt;
      echo &#039;&amp;lt;button class=&amp;quot;btn btn-primary validate&amp;quot; type=&amp;quot;submit&amp;quot;&amp;gt;&#039;.JText::_(&#039;JSUBMIT&#039;).&#039;&amp;lt;/button&amp;gt;&#039;;&lt;br /&gt;
      echo &#039;&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;mod_yourmodule&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&#039;;&lt;br /&gt;
      echo JHtml::_(&#039;form.token&#039;);&lt;br /&gt;
	}&lt;br /&gt;
	?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/fieldset&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will make some changes to this code, when we add Ajax handling to the module. Add this if you first want to test the form without Ajax.&lt;br /&gt;
&lt;br /&gt;
=== Load and use the model ===&lt;br /&gt;
&lt;br /&gt;
We load the message model and use it to get our form.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.php Use a model  ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
   defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
   //the class suffix from parameter&lt;br /&gt;
   $moduleclass_sfx = htmlspecialchars($params-&amp;gt;get(&#039;moduleclass_sfx&#039;));&lt;br /&gt;
&lt;br /&gt;
   $jinput = JFactory::getApplication()-&amp;gt;input;&lt;br /&gt;
&lt;br /&gt;
   $messageSent = $jinput-&amp;gt;post-&amp;gt;get( &#039;mod_yourmodule&#039;, 0, &#039;INT&#039;);&lt;br /&gt;
&lt;br /&gt;
   if ($messageSent)&lt;br /&gt;
   {&lt;br /&gt;
      //check the security token&lt;br /&gt;
      JSession::checkToken() or jexit(JText::_( &#039;JINVALID_TOKEN&#039; ));&lt;br /&gt;
&lt;br /&gt;
      $data     = $jinput-&amp;gt;post-&amp;gt;get( &#039;jform&#039;, array(), &#039;ARRAY&#039; );&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Include the helper that handles the data&lt;br /&gt;
   JLoader::import( &#039;helper&#039;,JPATH_ROOT .&#039;/modules/mod_yourmodule&#039; );&lt;br /&gt;
&lt;br /&gt;
   // Include the model that provide the form functionality&lt;br /&gt;
   JLoader::import( &#039;message&#039;,JPATH_ROOT .&#039;/modules/mod_yourmodule/models&#039; );&lt;br /&gt;
&lt;br /&gt;
   $model = JModelLegacy::getInstance( &#039;Message&#039;, &#039;YourmoduleModel&#039;, array(&#039;ignore_request&#039; =&amp;gt; true));&lt;br /&gt;
&lt;br /&gt;
   $form = $model-&amp;gt;getForm( array() , $loadData = true);&lt;br /&gt;
&lt;br /&gt;
   if ($messageSent)&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
      // Test whether the data is valid.&lt;br /&gt;
      $validData = $model-&amp;gt;validate( $form, $data );&lt;br /&gt;
&lt;br /&gt;
      // Check for validation errors.&lt;br /&gt;
      if ( $validData === false )&lt;br /&gt;
      {&lt;br /&gt;
         JFactory::getApplication()-&amp;gt;enqueueMessage($model-&amp;gt;getError(), &#039;error&#039;);&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
         JFactory::getApplication()-&amp;gt;enqueueMessage(&#039;Thanks for sending us a message&#039;);&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
require JModuleHelper::getLayoutPath(&#039;mod_yourmodule&#039;, $params-&amp;gt;get(&#039;layout&#039;, &#039;default&#039;));&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note the lines:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
$jinput = JFactory::getApplication()-&amp;gt;input;&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
$data     = $jinput-&amp;gt;post-&amp;gt;get( &#039;jform&#039;, array(), &#039;ARRAY&#039; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That is the way you get data more secure from the HTTP request with Joomla  . In this case an array variable named jform from the $_POST. Default is an empty array. Do not use $_REQUEST directly.&lt;br /&gt;
See [[Retrieving_request_data_using_JInput|Retrieving request data using JInput]]&lt;br /&gt;
&lt;br /&gt;
We will make some changes to this code as well, when we add Ajax handling to the module. Add this if you first want to test the form without Ajax.&lt;br /&gt;
&lt;br /&gt;
If you chose to change the code, you should now see a submitable form in your module position.&lt;br /&gt;
&lt;br /&gt;
=== Add Ajax functionality ===&lt;br /&gt;
&lt;br /&gt;
We remind you of the best practice to use a component for Ajax response. Since Joomla! version 3.2 a new component com_ajax is included in the Joomla! package. If you don&#039;t have a component, you can use that to get more secure handling for modules and plugins. We will use this interface here.&lt;br /&gt;
&lt;br /&gt;
Read more [[Using_Joomla_Ajax_Interface|Using Joomla Ajax Interface]]. You can also follow the examples from that document.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_A_form_and_ajax&amp;diff=125342</id>
		<title>User:Over/Step by step to a Joomla Module - A form and ajax</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_A_form_and_ajax&amp;diff=125342"/>
		<updated>2014-09-10T16:20:12Z</updated>

		<summary type="html">&lt;p&gt;Over: /* mod_yourmodule.php Use a model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{underconstruction}}&lt;br /&gt;
&lt;br /&gt;
{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this part of the tutorial we will use the form functionality of Joomla!. In a second step we&#039;ll add the Joomla! Ajax functionality to the module. If you want to keep the custom module you created up till now, you should use the knowledge you&#039;ve got from this tutorial and fork it. i.e. you copy all the files to a new local folder and change all filenames to a new name. Then you change all texts in the files including the old module name to a new at your choise, create an installation file and install the new module. We will still use yourmodule as name, so you&#039;ll have to adopt your own as before.&lt;br /&gt;
&lt;br /&gt;
Ajax = short for asynchronous JavaScript + XML&lt;br /&gt;
{{Tip|We will not mention the name adoption anymore and be less specific about file update.}}&lt;br /&gt;
&lt;br /&gt;
If you have a MVC component related to your module, it&#039;s easier and recommended to include the form functionality a.k.a. JForm by using the components methods. We&#039;ll add it without a component in this example.&lt;br /&gt;
&lt;br /&gt;
Why use JForm for html forms? You get a lot for &amp;quot;free&amp;quot;, like fields html code, client and server side validation.&lt;br /&gt;
&lt;br /&gt;
We first need a xml form declaration. In the folder where you unzipped the downloaded file you can find a models folder. Copy this to your modules web &#039;root&#039; folder. A module doesn&#039;t follow the MVC pattern, but let us use models as folder name. For a component you&#039;ll find forms, fields and rules in this path. You can find examples of custom fields and rules in those folders.&lt;br /&gt;
&lt;br /&gt;
=== The form ===&lt;br /&gt;
Open models/forms/yourmodule_form.xml for edit.&lt;br /&gt;
&lt;br /&gt;
==== message.xml ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;form&amp;gt;&lt;br /&gt;
   &amp;lt;fieldset addfieldpath=&amp;quot;modules/mod_yourmodule/models/fields&amp;quot;&lt;br /&gt;
             addrulepath=&amp;quot;modules/mod_yourmodule/models/rules&amp;quot;&amp;gt;  &lt;br /&gt;
      &amp;lt;field name=&amp;quot;subject&amp;quot;&lt;br /&gt;
         type=&amp;quot;text&amp;quot;&lt;br /&gt;
         size=&amp;quot;60&amp;quot;&lt;br /&gt;
         description=&amp;quot;MOD_YOURMODULE_MESSAGE_SUBJECT_DESC&amp;quot;&lt;br /&gt;
         label=&amp;quot;MOD_YOURMODULE_MESSAGE_SUBJECT_LABEL&amp;quot;&lt;br /&gt;
         filter=&amp;quot;string&amp;quot;&lt;br /&gt;
         validate=&amp;quot;yourmessagesubject&amp;quot;&lt;br /&gt;
         required=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;field name=&amp;quot;message&amp;quot;&lt;br /&gt;
         type=&amp;quot;textarea&amp;quot;&lt;br /&gt;
         cols=&amp;quot;50&amp;quot;&lt;br /&gt;
         rows=&amp;quot;10&amp;quot;&lt;br /&gt;
         description=&amp;quot;MOD_YOURMODULE_ENTER_MESSAGE_DESC&amp;quot;&lt;br /&gt;
         label=&amp;quot;MOD_YOURMODULE_ENTER_MESSAGE_LABEL&amp;quot;&lt;br /&gt;
         filter=&amp;quot;safehtml&amp;quot;&lt;br /&gt;
         validate=&amp;quot;yourmessage&amp;quot;&lt;br /&gt;
         required=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To be able to use our own fields and rules we add &#039;addfieldpath&#039; and &#039;addrulepath&#039;. Explaning the details of the declarations is outside the scope of this tutorial. Only so far: we add two fields &#039;subject&#039; and &#039;message&#039;. As you can see we use the same xml pattern as is used for the module options. Change the labels and descriptions. Do &#039;&#039;&#039;NOT&#039;&#039;&#039; change &#039;your&#039; in the validate lines or you have to edit the rules files. &lt;br /&gt;
&lt;br /&gt;
More about [[Form_field|Form fields]]&lt;br /&gt;
&lt;br /&gt;
You can find examples of form declarations in the core components. e,g. /administrator/com_content/models/forms/article.xml&lt;br /&gt;
&lt;br /&gt;
=== The language strings ===&lt;br /&gt;
&lt;br /&gt;
We have to add the language strings to the .ini file&lt;br /&gt;
&lt;br /&gt;
==== en-GB.mod_yourmodule.ini Form texts ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_MESSAGE_SUBJECT_DESC=&amp;quot;The subject of yor message&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_MESSAGE_SUBJECT_LABEL=&amp;quot;Subject&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_ENTER_MESSAGE_DESC=&amp;quot;Add your message&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_ENTER_MESSAGE_LABEL=&amp;quot;Message&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add the form to the output ===&lt;br /&gt;
&lt;br /&gt;
==== default.php With a form ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;A form your module&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;form id=&amp;quot;mod_yourmodule_&amp;lt;?php echo $module-&amp;gt;id;?&amp;gt;&amp;quot; action=&amp;quot;&amp;lt;?php echo JRoute::_(&#039;index.php&#039;); ?&amp;gt;&amp;quot; method=&amp;quot;post&amp;quot; class=&amp;quot;form-validate&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;fieldset class=&amp;quot;well&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;?php&lt;br /&gt;
      echo $form-&amp;gt;renderField(&#039;subject&#039;);&lt;br /&gt;
      echo $form-&amp;gt;renderField(&#039;message&#039;);&lt;br /&gt;
&lt;br /&gt;
   if (!$messageSent)&lt;br /&gt;
   {&lt;br /&gt;
      echo &#039;&amp;lt;button class=&amp;quot;btn btn-primary validate&amp;quot; type=&amp;quot;submit&amp;quot;&amp;gt;&#039;.JText::_(&#039;JSUBMIT&#039;).&#039;&amp;lt;/button&amp;gt;&#039;;&lt;br /&gt;
      echo &#039;&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;mod_yourmodule&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&#039;;&lt;br /&gt;
      echo JHtml::_(&#039;form.token&#039;);&lt;br /&gt;
	}&lt;br /&gt;
	?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/fieldset&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will make some changes to this code, when we add Ajax handling to the module. Add this if you first want to test the form without Ajax.&lt;br /&gt;
&lt;br /&gt;
=== Load and use the model ===&lt;br /&gt;
&lt;br /&gt;
We load the message model and use it to get our form.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.php Use a model  ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
   defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
   //the class suffix from parameter&lt;br /&gt;
   $moduleclass_sfx = htmlspecialchars($params-&amp;gt;get(&#039;moduleclass_sfx&#039;));&lt;br /&gt;
&lt;br /&gt;
   $jinput = JFactory::getApplication()-&amp;gt;input;&lt;br /&gt;
&lt;br /&gt;
   $messageSent = $jinput-&amp;gt;post-&amp;gt;get( &#039;mod_yourmodule&#039;, 0, &#039;INT&#039;);&lt;br /&gt;
&lt;br /&gt;
   if ($messageSent)&lt;br /&gt;
   {&lt;br /&gt;
      //check the security token&lt;br /&gt;
      JSession::checkToken() or jexit(JText::_( &#039;JINVALID_TOKEN&#039; ));&lt;br /&gt;
&lt;br /&gt;
      $data     = $jinput-&amp;gt;post-&amp;gt;get( &#039;jform&#039;, array(), &#039;ARRAY&#039; );&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Include the helper that handles the data&lt;br /&gt;
   JLoader::import( &#039;helper&#039;,JPATH_ROOT .&#039;/modules/mod_yourmodule&#039; );&lt;br /&gt;
&lt;br /&gt;
   // Include the model that provide the form functionality&lt;br /&gt;
   JLoader::import( &#039;message&#039;,JPATH_ROOT .&#039;/modules/mod_yourmodule/models&#039; );&lt;br /&gt;
&lt;br /&gt;
   $model = JModelLegacy::getInstance( &#039;Message&#039;, &#039;YourmoduleModel&#039;, array(&#039;ignore_request&#039; =&amp;gt; true));&lt;br /&gt;
&lt;br /&gt;
   $form = $model-&amp;gt;getForm( array() , $loadData = true);&lt;br /&gt;
&lt;br /&gt;
   if ($messageSent)&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
      // Test whether the data is valid.&lt;br /&gt;
      $validData = $model-&amp;gt;validate( $form, $data );&lt;br /&gt;
&lt;br /&gt;
      // Check for validation errors.&lt;br /&gt;
      if ( $validData === false )&lt;br /&gt;
      {&lt;br /&gt;
         JFactory::getApplication()-&amp;gt;enqueueMessage($model-&amp;gt;getError(), &#039;error&#039;);&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
         JFactory::getApplication()-&amp;gt;enqueueMessage(&#039;Thanks for sending us a message&#039;);&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
require JModuleHelper::getLayoutPath(&#039;mod_yourmodule&#039;, $params-&amp;gt;get(&#039;layout&#039;, &#039;default&#039;));&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note the lines:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
$jinput = JFactory::getApplication()-&amp;gt;input;&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
$data     = $jinput-&amp;gt;post-&amp;gt;get( &#039;jform&#039;, array(), &#039;ARRAY&#039; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That is the way you get data more secure from the HTTP request with Joomla  . In this case an array variable named jformfrom the $_POST. Default is an empty array. Do not use $_REQUEST directly.&lt;br /&gt;
See [[Retrieving_request_data_using_JInput|Retrieving request data using JInput]]&lt;br /&gt;
&lt;br /&gt;
We will make some changes to this code as well, when we add Ajax handling to the module. Add this if you first want to test the form without Ajax.&lt;br /&gt;
&lt;br /&gt;
If you chose to change the code, you should now see a submitable form in your module position.&lt;br /&gt;
&lt;br /&gt;
=== Add Ajax functionality ===&lt;br /&gt;
&lt;br /&gt;
We remind you of the best practice to use a component for Ajax response. Since Joomla! version 3.2 a new component com_ajax is included in the Joomla! package. If you don&#039;t have a component, you can use that to get more secure handling for modules and plugins. We will use this interface here.&lt;br /&gt;
&lt;br /&gt;
Read more [[Using_Joomla_Ajax_Interface|Using Joomla Ajax Interface]]. You can also follow the examples from that document.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125323</id>
		<title>User:Over/Step by step to a Joomla Module - Data retrieval and styling</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125323"/>
		<updated>2014-09-10T15:42:12Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Use a component for data retrieval */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to retrieve data from a database table in two ways, direct access to a table and using a components methods. You have to have installed the module you created in former parts of the tutorial, before you start to follow this part.&lt;br /&gt;
&lt;br /&gt;
=== Data retrieval ===&lt;br /&gt;
&lt;br /&gt;
As in the previous parts you copy a skeleton file to your module folder in your Joomla path of the server. This time you copy the helper.php file to the &amp;quot;root&amp;quot; of the module.&lt;br /&gt;
&lt;br /&gt;
==== helper.php ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
abstract class ModYourmoduleHelper&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
		//we will add some code here&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The top of the file looks like any other of our php files. Copy your own comment lines from one of the php files you have edited in the former parts of the tutorial. Then we have a class definition with a name following a convention you as well should follow. Mod + The module name + Helper. A comment block follows describing what the following function does. We will add our code within the function ( in developer language called method ). You have to read the coding standards or have a look in any Joomla! core php file to learn more about coding and commenting conventions.&lt;br /&gt;
&lt;br /&gt;
We will use an article to have a litle more dynamic data example. If you didn&#039;t create an article earlier in this tutorial series do that now. Keep it short as it&#039;s only an example. In the Module Manager you open your module and under the option tab you choose your article example. You see the title but actually the article id number is stored as parameter value.&lt;br /&gt;
&lt;br /&gt;
In the first example we&#039;ll get the article text by sending sql statements to the Joomla! database API.&lt;br /&gt;
&lt;br /&gt;
==== helper.php - The sql commands ====&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		//get the users authorisations&lt;br /&gt;
		$user       = JFactory::getUser();&lt;br /&gt;
		$groups     = implode(&#039;,&#039;, $user-&amp;gt;getAuthorisedViewLevels());&lt;br /&gt;
&lt;br /&gt;
		$db = JFactory::getDbo();&lt;br /&gt;
   		//get a db query object&lt;br /&gt;
		$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
		//select article id, title and introtext&lt;br /&gt;
		$query-&amp;gt;select(&lt;br /&gt;
			array(&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.id&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.title&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.introtext&#039;),&lt;br /&gt;
				)&lt;br /&gt;
		);&lt;br /&gt;
   		//from the article table&lt;br /&gt;
		$query-&amp;gt;from($db-&amp;gt;quoteName(&#039;#__content&#039;, &#039;a&#039;));&lt;br /&gt;
		//id from parameter, we cast to integer&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;id&#039;) . &#039; = &#039;. (int) $id);&lt;br /&gt;
		// Only return if published&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;a.state&#039;) . &#039; = 1 &#039;);&lt;br /&gt;
		//and user is authorised to read&lt;br /&gt;
                $query-&amp;gt;where($this-&amp;gt;db-&amp;gt;quoteName(&#039;a.access&#039;) . &#039; IN (&#039; . $groups . &#039;)&#039;);&lt;br /&gt;
&lt;br /&gt;
		//uncomment this line to see the query string&lt;br /&gt;
		//echo $query;&lt;br /&gt;
&lt;br /&gt;
		$db-&amp;gt;setQuery($query);&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
	   		//get the article&lt;br /&gt;
			$result = $db-&amp;gt;loadObject();&lt;br /&gt;
		}&lt;br /&gt;
   		//check error&lt;br /&gt;
		catch (RuntimeException $e)&lt;br /&gt;
		{&lt;br /&gt;
			//this is a module so we skip it if there are errors&lt;br /&gt;
			// in other cases we would show a message&lt;br /&gt;
			//$app = JFactory::getApplication();&lt;br /&gt;
			//$app-&amp;gt;enqueueMessage($e-&amp;gt;getMessage(), &#039;error&#039;);&lt;br /&gt;
&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $result;&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the brief comments in the text about what we are doing here. &lt;br /&gt;
&lt;br /&gt;
Important security issue: use $db-&amp;gt;quote($field_value) to avoid so called &amp;quot;sql-injections&amp;quot; for none integer or float variables. Use (int) and (float) for those. Be very careful when you build sql queries. &lt;br /&gt;
&lt;br /&gt;
db-&amp;gt;quoteName(&#039;field_name&#039;) escapes the name database dependent. We can&#039;t describe more details to Joomla! sql queries within this tutorial. More in [http://docs.joomla.org/Accessing_the_database_using_JDatabase Accessing the database using JDatabase]&lt;br /&gt;
&lt;br /&gt;
As this is a module we don&#039;t show errormessages to the user. If there are errors the page will still be ok.&lt;br /&gt;
&lt;br /&gt;
Copy the code to your helper.php replacing the method ( = function ) getData.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The helper file is loaded and run from mod_yourmodule.php. Open it and add the following between defined(... and require.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.php - Load helper class ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    // Include the helper file that provide the data&lt;br /&gt;
   require __DIR__ . &#039;/helper.php&#039;;&lt;br /&gt;
&lt;br /&gt;
   //the class suffix from parameter&lt;br /&gt;
   $moduleclass_sfx = htmlspecialchars($params-&amp;gt;get(&#039;moduleclass_sfx&#039;));&lt;br /&gt;
 &lt;br /&gt;
  if ( !$article = ModYourmoduleHelper::getData($params))&lt;br /&gt;
   {&lt;br /&gt;
      //if error or article not found skip this module&lt;br /&gt;
      return false;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //uncomment this line to see the available fields&lt;br /&gt;
   //var_dump($article);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the same time we get the class suffix from the parameter. Explained below.&lt;br /&gt;
Now that you have the article data, we will change the output file to show it. Remember? /tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
==== default.php - Show article ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After defined(... and the php closing tab we change the html. We use embedded php code to echo the title and the introtext. We add a module specific class $moduleclass sfx to the div tag. $moduleclass sfx is the class suffix the user can add in the Module Manager -&amp;amp;gt; tab Advanced. This can be used for Css styling if multiple instances of the same module are enabled. e.g. you can test to reuse your module by choosing another article. We will style them in the next step.&lt;br /&gt;
&lt;br /&gt;
You can test your module before adding the Css.&lt;br /&gt;
&lt;br /&gt;
=== Css styling ===&lt;br /&gt;
Best practice on a website is to &#039;&#039;&#039;try&#039;&#039;&#039; to keep all css styling in one file. As you don&#039;t know if the users template shows your module as designed, you have to include a css file. Not really for what we have above, but in a tutorial we do as if. You should use the parameters we created in a former part, to let the user of the module exclude your css. Described in the Overrides part of the tutorial.&lt;br /&gt;
&lt;br /&gt;
We will not only prepare for loading css but also for images and javascript. Best practice is to store those files in subfolders of the Joomla media folder. Please don&#039;t ask why this folder was named media.&lt;br /&gt;
&lt;br /&gt;
Create folder path/to/your/joomla/media/mod_yourmodule. In the folder where you unpacked the tutorial zip file you&#039;ll find a media folder. Open this and copy all three subfolders to the new folder in your web folder. It should result in something like this &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/logs&lt;br /&gt;
/media&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /css                   *new directory*&lt;br /&gt;
      yourmodule.css       *new file*&lt;br /&gt;
    /images                *new directory*&lt;br /&gt;
      doc.png              *new file*&lt;br /&gt;
      yourmodule-logo.png  *new file*&lt;br /&gt;
    /js                    *new directory*&lt;br /&gt;
      yourmodule.js        *new file*&lt;br /&gt;
      yourmodule_ajax.js   *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/modules&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Did you use your module name? You don´t have to, but it´s a good practice to use distinct names.&lt;br /&gt;
&lt;br /&gt;
=== Add Css file  ===&lt;br /&gt;
&lt;br /&gt;
We include the module specific css file to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
==== default.php - Include Css file and image ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div class=&amp;quot;row text-center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;?php echo JHtml::image(&#039;mod_yourmodule/yourmodule-logo.png&#039;, &#039;Yourmodule logo&#039;, &#039;&#039;, true, false );?&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this code added yourmodule.css will be loaded from the path media/mod_yourmodule/css/&lt;br /&gt;
Be aware of the missing /css/ ! This is added by Joomla. The image will be loaded from the path media/mod_yourmodule/images/.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s test that the css is working by adding a few lines to the yourmodule.css file. Open it with the editor and add e.g. those lines that change text color. Do we have to mention the module name that was used as css class?&lt;br /&gt;
&lt;br /&gt;
==== yourmodule.css ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
.yourmodule h4{&lt;br /&gt;
	color: #08c;&lt;br /&gt;
}&lt;br /&gt;
.yourmodule p {&lt;br /&gt;
	color: #005580;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On your frontend page the colors should have changed and an image added. Have a look! Be aware that your browser may have cached the css.&lt;br /&gt;
&lt;br /&gt;
=== Update the xml and the zip file  ===&lt;br /&gt;
&lt;br /&gt;
Now we have to add the new files to the xml file and create an updated installation zip file.&lt;br /&gt;
&lt;br /&gt;
Add the helper.php and the special media tag to the xml file.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add helper.php ====&lt;br /&gt;
&lt;br /&gt;
Add helper.php to the files tag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;files&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;helper.php&amp;lt;/filename&amp;gt; &lt;br /&gt;
		&amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add media folder ====&lt;br /&gt;
&lt;br /&gt;
Add the media tag between files and languages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
	&amp;lt;media destination=&amp;quot;mod_yourmodule&amp;quot; folder=&amp;quot;media&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;css&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;images&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;js&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/media&amp;gt;&lt;br /&gt;
	&amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== Create the installation file ===&lt;br /&gt;
&lt;br /&gt;
Now you copy &#039;&#039;&#039;all&#039;&#039;&#039; module files from the server to the path &#039;somewhere&#039;/j_module_tutorial/new_module as in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
Create a new folder &#039;media&#039; and copy the three folders from media/mod_yourmodule.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  .../new_module&lt;br /&gt;
      /langs&lt;br /&gt;
        en-GB.mod_yourmodule.ini&lt;br /&gt;
        en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        anyother-language.mod_yourmodule.in&lt;br /&gt;
        anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /language&lt;br /&gt;
        /en-GB&lt;br /&gt;
          en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        /anyother-language&lt;br /&gt;
          anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /media&lt;br /&gt;
        /css&lt;br /&gt;
          yourmodule.css&lt;br /&gt;
        /images&lt;br /&gt;
          doc.png&lt;br /&gt;
          yourmodule-logo.png&lt;br /&gt;
        /js&lt;br /&gt;
          yourmodule.js&lt;br /&gt;
      /tmpl&lt;br /&gt;
        default.php&lt;br /&gt;
      mod_yourmodule.php&lt;br /&gt;
      mod_yourmodule.xml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the compressed installation zip file as described in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this tutorial part. Below we describe an alternative for data retrieval.&lt;br /&gt;
&lt;br /&gt;
=== Use a component for data retrieval ===&lt;br /&gt;
&lt;br /&gt;
Below is an alternative to using direct sql. You can use the methods provided by a component to retrieve the data. If you develop your own component, you can prepare methods for reuse, otherwise you can try to find a method in a components models to retrieve the data you want. Here we reuse the getItem method of the content component ( articles ). In this case you get all article data returned. If you use a lot of modules of this type on the same page, be a little aware of memory usage. If you want to test it, you only have to replace the getData method in helper.php.&lt;br /&gt;
&lt;br /&gt;
To see the data available you can uncomment the var_dump line in mod_yourmodule.php.&lt;br /&gt;
&lt;br /&gt;
==== helper.php Use of component ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model = JModelLegacy::getInstance(&#039;Article&#039;, &#039;ContentModel&#039;, array(&#039;ignore_request&#039; =&amp;gt; true));&lt;br /&gt;
&lt;br /&gt;
		$app = JFactory::getApplication(&#039;site&#039;);&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;article.id&#039;, $id);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;list.offset&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
		// Load the parameters.&lt;br /&gt;
		$params = $app-&amp;gt;getParams(&#039;com_content&#039;);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;params&#039;, $params);&lt;br /&gt;
&lt;br /&gt;
		$user = JFactory::getUser();&lt;br /&gt;
&lt;br /&gt;
		if ((!$user-&amp;gt;authorise(&#039;core.edit.state&#039;, &#039;com_content&#039;)) &amp;amp;&amp;amp; (!$user-&amp;gt;authorise(&#039;core.edit&#039;, &#039;com_content&#039;)))&lt;br /&gt;
		{&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.published&#039;, 1);&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.archived&#039;, 2);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;filter.language&#039;, JLanguageMultilang::isEnabled());&lt;br /&gt;
  		&lt;br /&gt;
 		return $model-&amp;gt;getItem($id);;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add javascript to the module ===&lt;br /&gt;
&lt;br /&gt;
If you want to use javascript for yourmodule, here is an example. It loads the javascript file in the media/mod_yourmodule/js path and adds a script to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
Read more [[J3.x:Javascript_Frameworks|J3.x:Javascript Frameworks]]&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
   $document = JFactory::getDocument();&lt;br /&gt;
   $document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this code below the line that loads the css file if you want to test it.&lt;br /&gt;
&lt;br /&gt;
* We use jQuery so we have to load it &#039;&#039;&#039;before&#039;&#039;&#039; our own modules script. Here we load the Bootstrap framework that also includes jQuery. Use JHtml::_(&#039;jquery.framework&#039;) if you only need this.&lt;br /&gt;
* We add our scriptfile &amp;quot;relative&amp;quot; to the media folder.&lt;br /&gt;
* We add the script declaration directly to the document object. It gets added to the header in the html document.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125322</id>
		<title>User:Over/Step by step to a Joomla Module - Data retrieval and styling</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125322"/>
		<updated>2014-09-10T15:40:26Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Create the installation file */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to retrieve data from a database table in two ways, direct access to a table and using a components methods. You have to have installed the module you created in former parts of the tutorial, before you start to follow this part.&lt;br /&gt;
&lt;br /&gt;
=== Data retrieval ===&lt;br /&gt;
&lt;br /&gt;
As in the previous parts you copy a skeleton file to your module folder in your Joomla path of the server. This time you copy the helper.php file to the &amp;quot;root&amp;quot; of the module.&lt;br /&gt;
&lt;br /&gt;
==== helper.php ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
abstract class ModYourmoduleHelper&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
		//we will add some code here&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The top of the file looks like any other of our php files. Copy your own comment lines from one of the php files you have edited in the former parts of the tutorial. Then we have a class definition with a name following a convention you as well should follow. Mod + The module name + Helper. A comment block follows describing what the following function does. We will add our code within the function ( in developer language called method ). You have to read the coding standards or have a look in any Joomla! core php file to learn more about coding and commenting conventions.&lt;br /&gt;
&lt;br /&gt;
We will use an article to have a litle more dynamic data example. If you didn&#039;t create an article earlier in this tutorial series do that now. Keep it short as it&#039;s only an example. In the Module Manager you open your module and under the option tab you choose your article example. You see the title but actually the article id number is stored as parameter value.&lt;br /&gt;
&lt;br /&gt;
In the first example we&#039;ll get the article text by sending sql statements to the Joomla! database API.&lt;br /&gt;
&lt;br /&gt;
==== helper.php - The sql commands ====&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		//get the users authorisations&lt;br /&gt;
		$user       = JFactory::getUser();&lt;br /&gt;
		$groups     = implode(&#039;,&#039;, $user-&amp;gt;getAuthorisedViewLevels());&lt;br /&gt;
&lt;br /&gt;
		$db = JFactory::getDbo();&lt;br /&gt;
   		//get a db query object&lt;br /&gt;
		$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
		//select article id, title and introtext&lt;br /&gt;
		$query-&amp;gt;select(&lt;br /&gt;
			array(&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.id&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.title&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.introtext&#039;),&lt;br /&gt;
				)&lt;br /&gt;
		);&lt;br /&gt;
   		//from the article table&lt;br /&gt;
		$query-&amp;gt;from($db-&amp;gt;quoteName(&#039;#__content&#039;, &#039;a&#039;));&lt;br /&gt;
		//id from parameter, we cast to integer&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;id&#039;) . &#039; = &#039;. (int) $id);&lt;br /&gt;
		// Only return if published&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;a.state&#039;) . &#039; = 1 &#039;);&lt;br /&gt;
		//and user is authorised to read&lt;br /&gt;
                $query-&amp;gt;where($this-&amp;gt;db-&amp;gt;quoteName(&#039;a.access&#039;) . &#039; IN (&#039; . $groups . &#039;)&#039;);&lt;br /&gt;
&lt;br /&gt;
		//uncomment this line to see the query string&lt;br /&gt;
		//echo $query;&lt;br /&gt;
&lt;br /&gt;
		$db-&amp;gt;setQuery($query);&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
	   		//get the article&lt;br /&gt;
			$result = $db-&amp;gt;loadObject();&lt;br /&gt;
		}&lt;br /&gt;
   		//check error&lt;br /&gt;
		catch (RuntimeException $e)&lt;br /&gt;
		{&lt;br /&gt;
			//this is a module so we skip it if there are errors&lt;br /&gt;
			// in other cases we would show a message&lt;br /&gt;
			//$app = JFactory::getApplication();&lt;br /&gt;
			//$app-&amp;gt;enqueueMessage($e-&amp;gt;getMessage(), &#039;error&#039;);&lt;br /&gt;
&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $result;&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the brief comments in the text about what we are doing here. &lt;br /&gt;
&lt;br /&gt;
Important security issue: use $db-&amp;gt;quote($field_value) to avoid so called &amp;quot;sql-injections&amp;quot; for none integer or float variables. Use (int) and (float) for those. Be very careful when you build sql queries. &lt;br /&gt;
&lt;br /&gt;
db-&amp;gt;quoteName(&#039;field_name&#039;) escapes the name database dependent. We can&#039;t describe more details to Joomla! sql queries within this tutorial. More in [http://docs.joomla.org/Accessing_the_database_using_JDatabase Accessing the database using JDatabase]&lt;br /&gt;
&lt;br /&gt;
As this is a module we don&#039;t show errormessages to the user. If there are errors the page will still be ok.&lt;br /&gt;
&lt;br /&gt;
Copy the code to your helper.php replacing the method ( = function ) getData.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The helper file is loaded and run from mod_yourmodule.php. Open it and add the following between defined(... and require.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.php - Load helper class ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    // Include the helper file that provide the data&lt;br /&gt;
   require __DIR__ . &#039;/helper.php&#039;;&lt;br /&gt;
&lt;br /&gt;
   //the class suffix from parameter&lt;br /&gt;
   $moduleclass_sfx = htmlspecialchars($params-&amp;gt;get(&#039;moduleclass_sfx&#039;));&lt;br /&gt;
 &lt;br /&gt;
  if ( !$article = ModYourmoduleHelper::getData($params))&lt;br /&gt;
   {&lt;br /&gt;
      //if error or article not found skip this module&lt;br /&gt;
      return false;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //uncomment this line to see the available fields&lt;br /&gt;
   //var_dump($article);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the same time we get the class suffix from the parameter. Explained below.&lt;br /&gt;
Now that you have the article data, we will change the output file to show it. Remember? /tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
==== default.php - Show article ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After defined(... and the php closing tab we change the html. We use embedded php code to echo the title and the introtext. We add a module specific class $moduleclass sfx to the div tag. $moduleclass sfx is the class suffix the user can add in the Module Manager -&amp;amp;gt; tab Advanced. This can be used for Css styling if multiple instances of the same module are enabled. e.g. you can test to reuse your module by choosing another article. We will style them in the next step.&lt;br /&gt;
&lt;br /&gt;
You can test your module before adding the Css.&lt;br /&gt;
&lt;br /&gt;
=== Css styling ===&lt;br /&gt;
Best practice on a website is to &#039;&#039;&#039;try&#039;&#039;&#039; to keep all css styling in one file. As you don&#039;t know if the users template shows your module as designed, you have to include a css file. Not really for what we have above, but in a tutorial we do as if. You should use the parameters we created in a former part, to let the user of the module exclude your css. Described in the Overrides part of the tutorial.&lt;br /&gt;
&lt;br /&gt;
We will not only prepare for loading css but also for images and javascript. Best practice is to store those files in subfolders of the Joomla media folder. Please don&#039;t ask why this folder was named media.&lt;br /&gt;
&lt;br /&gt;
Create folder path/to/your/joomla/media/mod_yourmodule. In the folder where you unpacked the tutorial zip file you&#039;ll find a media folder. Open this and copy all three subfolders to the new folder in your web folder. It should result in something like this &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/logs&lt;br /&gt;
/media&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /css                   *new directory*&lt;br /&gt;
      yourmodule.css       *new file*&lt;br /&gt;
    /images                *new directory*&lt;br /&gt;
      doc.png              *new file*&lt;br /&gt;
      yourmodule-logo.png  *new file*&lt;br /&gt;
    /js                    *new directory*&lt;br /&gt;
      yourmodule.js        *new file*&lt;br /&gt;
      yourmodule_ajax.js   *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/modules&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Did you use your module name? You don´t have to, but it´s a good practice to use distinct names.&lt;br /&gt;
&lt;br /&gt;
=== Add Css file  ===&lt;br /&gt;
&lt;br /&gt;
We include the module specific css file to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
==== default.php - Include Css file and image ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div class=&amp;quot;row text-center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;?php echo JHtml::image(&#039;mod_yourmodule/yourmodule-logo.png&#039;, &#039;Yourmodule logo&#039;, &#039;&#039;, true, false );?&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this code added yourmodule.css will be loaded from the path media/mod_yourmodule/css/&lt;br /&gt;
Be aware of the missing /css/ ! This is added by Joomla. The image will be loaded from the path media/mod_yourmodule/images/.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s test that the css is working by adding a few lines to the yourmodule.css file. Open it with the editor and add e.g. those lines that change text color. Do we have to mention the module name that was used as css class?&lt;br /&gt;
&lt;br /&gt;
==== yourmodule.css ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
.yourmodule h4{&lt;br /&gt;
	color: #08c;&lt;br /&gt;
}&lt;br /&gt;
.yourmodule p {&lt;br /&gt;
	color: #005580;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On your frontend page the colors should have changed and an image added. Have a look! Be aware that your browser may have cached the css.&lt;br /&gt;
&lt;br /&gt;
=== Update the xml and the zip file  ===&lt;br /&gt;
&lt;br /&gt;
Now we have to add the new files to the xml file and create an updated installation zip file.&lt;br /&gt;
&lt;br /&gt;
Add the helper.php and the special media tag to the xml file.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add helper.php ====&lt;br /&gt;
&lt;br /&gt;
Add helper.php to the files tag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;files&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;helper.php&amp;lt;/filename&amp;gt; &lt;br /&gt;
		&amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add media folder ====&lt;br /&gt;
&lt;br /&gt;
Add the media tag between files and languages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
	&amp;lt;media destination=&amp;quot;mod_yourmodule&amp;quot; folder=&amp;quot;media&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;css&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;images&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;js&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/media&amp;gt;&lt;br /&gt;
	&amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== Create the installation file ===&lt;br /&gt;
&lt;br /&gt;
Now you copy &#039;&#039;&#039;all&#039;&#039;&#039; module files from the server to the path &#039;somewhere&#039;/j_module_tutorial/new_module as in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
Create a new folder &#039;media&#039; and copy the three folders from media/mod_yourmodule.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  .../new_module&lt;br /&gt;
      /langs&lt;br /&gt;
        en-GB.mod_yourmodule.ini&lt;br /&gt;
        en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        anyother-language.mod_yourmodule.in&lt;br /&gt;
        anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /language&lt;br /&gt;
        /en-GB&lt;br /&gt;
          en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        /anyother-language&lt;br /&gt;
          anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /media&lt;br /&gt;
        /css&lt;br /&gt;
          yourmodule.css&lt;br /&gt;
        /images&lt;br /&gt;
          doc.png&lt;br /&gt;
          yourmodule-logo.png&lt;br /&gt;
        /js&lt;br /&gt;
          yourmodule.js&lt;br /&gt;
      /tmpl&lt;br /&gt;
        default.php&lt;br /&gt;
      mod_yourmodule.php&lt;br /&gt;
      mod_yourmodule.xml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the compressed installation zip file as described in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this tutorial part. Below we describe an alternative for data retrieval.&lt;br /&gt;
&lt;br /&gt;
=== Use a component for data retrieval ===&lt;br /&gt;
&lt;br /&gt;
Below is an alternative to using direct sql. You can use the methods provided by a component to retrieve the data. If you develop your own component, you can prepare methods for reuse, otherwise you can try to find a method in a components models to retrieve the data you want. Here we reuse the getItem method of the content component ( articles ). In this case you get all article data returned. If you use a lot of modules of this type on the same page, be a little aware of momory usage. If you want to test it, you only have to replace the getData method in helper.php.&lt;br /&gt;
&lt;br /&gt;
To see the data available you can uncomment the var_dump line in mod_yourmodule.php.&lt;br /&gt;
&lt;br /&gt;
==== helper.php Use of component ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model = JModelLegacy::getInstance(&#039;Article&#039;, &#039;ContentModel&#039;, array(&#039;ignore_request&#039; =&amp;gt; true));&lt;br /&gt;
&lt;br /&gt;
		$app = JFactory::getApplication(&#039;site&#039;);&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;article.id&#039;, $id);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;list.offset&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
		// Load the parameters.&lt;br /&gt;
		$params = $app-&amp;gt;getParams(&#039;com_content&#039;);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;params&#039;, $params);&lt;br /&gt;
&lt;br /&gt;
		$user = JFactory::getUser();&lt;br /&gt;
&lt;br /&gt;
		if ((!$user-&amp;gt;authorise(&#039;core.edit.state&#039;, &#039;com_content&#039;)) &amp;amp;&amp;amp; (!$user-&amp;gt;authorise(&#039;core.edit&#039;, &#039;com_content&#039;)))&lt;br /&gt;
		{&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.published&#039;, 1);&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.archived&#039;, 2);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;filter.language&#039;, JLanguageMultilang::isEnabled());&lt;br /&gt;
  		&lt;br /&gt;
 		return $model-&amp;gt;getItem($id);;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add javascript to the module ===&lt;br /&gt;
&lt;br /&gt;
If you want to use javascript for yourmodule, here is an example. It loads the javascript file in the media/mod_yourmodule/js path and adds a script to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
Read more [[J3.x:Javascript_Frameworks|J3.x:Javascript Frameworks]]&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
   $document = JFactory::getDocument();&lt;br /&gt;
   $document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this code below the line that loads the css file if you want to test it.&lt;br /&gt;
&lt;br /&gt;
* We use jQuery so we have to load it &#039;&#039;&#039;before&#039;&#039;&#039; our own modules script. Here we load the Bootstrap framework that also includes jQuery. Use JHtml::_(&#039;jquery.framework&#039;) if you only need this.&lt;br /&gt;
* We add our scriptfile &amp;quot;relative&amp;quot; to the media folder.&lt;br /&gt;
* We add the script declaration directly to the document object. It gets added to the header in the html document.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125319</id>
		<title>User:Over/Step by step to a Joomla Module - Data retrieval and styling</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125319"/>
		<updated>2014-09-10T15:35:09Z</updated>

		<summary type="html">&lt;p&gt;Over: /* default.php - Show article */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to retrieve data from a database table in two ways, direct access to a table and using a components methods. You have to have installed the module you created in former parts of the tutorial, before you start to follow this part.&lt;br /&gt;
&lt;br /&gt;
=== Data retrieval ===&lt;br /&gt;
&lt;br /&gt;
As in the previous parts you copy a skeleton file to your module folder in your Joomla path of the server. This time you copy the helper.php file to the &amp;quot;root&amp;quot; of the module.&lt;br /&gt;
&lt;br /&gt;
==== helper.php ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
abstract class ModYourmoduleHelper&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
		//we will add some code here&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The top of the file looks like any other of our php files. Copy your own comment lines from one of the php files you have edited in the former parts of the tutorial. Then we have a class definition with a name following a convention you as well should follow. Mod + The module name + Helper. A comment block follows describing what the following function does. We will add our code within the function ( in developer language called method ). You have to read the coding standards or have a look in any Joomla! core php file to learn more about coding and commenting conventions.&lt;br /&gt;
&lt;br /&gt;
We will use an article to have a litle more dynamic data example. If you didn&#039;t create an article earlier in this tutorial series do that now. Keep it short as it&#039;s only an example. In the Module Manager you open your module and under the option tab you choose your article example. You see the title but actually the article id number is stored as parameter value.&lt;br /&gt;
&lt;br /&gt;
In the first example we&#039;ll get the article text by sending sql statements to the Joomla! database API.&lt;br /&gt;
&lt;br /&gt;
==== helper.php - The sql commands ====&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		//get the users authorisations&lt;br /&gt;
		$user       = JFactory::getUser();&lt;br /&gt;
		$groups     = implode(&#039;,&#039;, $user-&amp;gt;getAuthorisedViewLevels());&lt;br /&gt;
&lt;br /&gt;
		$db = JFactory::getDbo();&lt;br /&gt;
   		//get a db query object&lt;br /&gt;
		$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
		//select article id, title and introtext&lt;br /&gt;
		$query-&amp;gt;select(&lt;br /&gt;
			array(&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.id&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.title&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.introtext&#039;),&lt;br /&gt;
				)&lt;br /&gt;
		);&lt;br /&gt;
   		//from the article table&lt;br /&gt;
		$query-&amp;gt;from($db-&amp;gt;quoteName(&#039;#__content&#039;, &#039;a&#039;));&lt;br /&gt;
		//id from parameter, we cast to integer&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;id&#039;) . &#039; = &#039;. (int) $id);&lt;br /&gt;
		// Only return if published&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;a.state&#039;) . &#039; = 1 &#039;);&lt;br /&gt;
		//and user is authorised to read&lt;br /&gt;
                $query-&amp;gt;where($this-&amp;gt;db-&amp;gt;quoteName(&#039;a.access&#039;) . &#039; IN (&#039; . $groups . &#039;)&#039;);&lt;br /&gt;
&lt;br /&gt;
		//uncomment this line to see the query string&lt;br /&gt;
		//echo $query;&lt;br /&gt;
&lt;br /&gt;
		$db-&amp;gt;setQuery($query);&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
	   		//get the article&lt;br /&gt;
			$result = $db-&amp;gt;loadObject();&lt;br /&gt;
		}&lt;br /&gt;
   		//check error&lt;br /&gt;
		catch (RuntimeException $e)&lt;br /&gt;
		{&lt;br /&gt;
			//this is a module so we skip it if there are errors&lt;br /&gt;
			// in other cases we would show a message&lt;br /&gt;
			//$app = JFactory::getApplication();&lt;br /&gt;
			//$app-&amp;gt;enqueueMessage($e-&amp;gt;getMessage(), &#039;error&#039;);&lt;br /&gt;
&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $result;&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the brief comments in the text about what we are doing here. &lt;br /&gt;
&lt;br /&gt;
Important security issue: use $db-&amp;gt;quote($field_value) to avoid so called &amp;quot;sql-injections&amp;quot; for none integer or float variables. Use (int) and (float) for those. Be very careful when you build sql queries. &lt;br /&gt;
&lt;br /&gt;
db-&amp;gt;quoteName(&#039;field_name&#039;) escapes the name database dependent. We can&#039;t describe more details to Joomla! sql queries within this tutorial. More in [http://docs.joomla.org/Accessing_the_database_using_JDatabase Accessing the database using JDatabase]&lt;br /&gt;
&lt;br /&gt;
As this is a module we don&#039;t show errormessages to the user. If there are errors the page will still be ok.&lt;br /&gt;
&lt;br /&gt;
Copy the code to your helper.php replacing the method ( = function ) getData.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The helper file is loaded and run from mod_yourmodule.php. Open it and add the following between defined(... and require.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.php - Load helper class ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    // Include the helper file that provide the data&lt;br /&gt;
   require __DIR__ . &#039;/helper.php&#039;;&lt;br /&gt;
&lt;br /&gt;
   //the class suffix from parameter&lt;br /&gt;
   $moduleclass_sfx = htmlspecialchars($params-&amp;gt;get(&#039;moduleclass_sfx&#039;));&lt;br /&gt;
 &lt;br /&gt;
  if ( !$article = ModYourmoduleHelper::getData($params))&lt;br /&gt;
   {&lt;br /&gt;
      //if error or article not found skip this module&lt;br /&gt;
      return false;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //uncomment this line to see the available fields&lt;br /&gt;
   //var_dump($article);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the same time we get the class suffix from the parameter. Explained below.&lt;br /&gt;
Now that you have the article data, we will change the output file to show it. Remember? /tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
==== default.php - Show article ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After defined(... and the php closing tab we change the html. We use embedded php code to echo the title and the introtext. We add a module specific class $moduleclass sfx to the div tag. $moduleclass sfx is the class suffix the user can add in the Module Manager -&amp;amp;gt; tab Advanced. This can be used for Css styling if multiple instances of the same module are enabled. e.g. you can test to reuse your module by choosing another article. We will style them in the next step.&lt;br /&gt;
&lt;br /&gt;
You can test your module before adding the Css.&lt;br /&gt;
&lt;br /&gt;
=== Css styling ===&lt;br /&gt;
Best practice on a website is to &#039;&#039;&#039;try&#039;&#039;&#039; to keep all css styling in one file. As you don&#039;t know if the users template shows your module as designed, you have to include a css file. Not really for what we have above, but in a tutorial we do as if. You should use the parameters we created in a former part, to let the user of the module exclude your css. Described in the Overrides part of the tutorial.&lt;br /&gt;
&lt;br /&gt;
We will not only prepare for loading css but also for images and javascript. Best practice is to store those files in subfolders of the Joomla media folder. Please don&#039;t ask why this folder was named media.&lt;br /&gt;
&lt;br /&gt;
Create folder path/to/your/joomla/media/mod_yourmodule. In the folder where you unpacked the tutorial zip file you&#039;ll find a media folder. Open this and copy all three subfolders to the new folder in your web folder. It should result in something like this &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/logs&lt;br /&gt;
/media&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /css                   *new directory*&lt;br /&gt;
      yourmodule.css       *new file*&lt;br /&gt;
    /images                *new directory*&lt;br /&gt;
      doc.png              *new file*&lt;br /&gt;
      yourmodule-logo.png  *new file*&lt;br /&gt;
    /js                    *new directory*&lt;br /&gt;
      yourmodule.js        *new file*&lt;br /&gt;
      yourmodule_ajax.js   *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/modules&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Did you use your module name? You don´t have to, but it´s a good practice to use distinct names.&lt;br /&gt;
&lt;br /&gt;
=== Add Css file  ===&lt;br /&gt;
&lt;br /&gt;
We include the module specific css file to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
==== default.php - Include Css file and image ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div class=&amp;quot;row text-center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;?php echo JHtml::image(&#039;mod_yourmodule/yourmodule-logo.png&#039;, &#039;Yourmodule logo&#039;, &#039;&#039;, true, false );?&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this code added yourmodule.css will be loaded from the path media/mod_yourmodule/css/&lt;br /&gt;
Be aware of the missing /css/ ! This is added by Joomla. The image will be loaded from the path media/mod_yourmodule/images/.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s test that the css is working by adding a few lines to the yourmodule.css file. Open it with the editor and add e.g. those lines that change text color. Do we have to mention the module name that was used as css class?&lt;br /&gt;
&lt;br /&gt;
==== yourmodule.css ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
.yourmodule h4{&lt;br /&gt;
	color: #08c;&lt;br /&gt;
}&lt;br /&gt;
.yourmodule p {&lt;br /&gt;
	color: #005580;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On your frontend page the colors should have changed and an image added. Have a look! Be aware that your browser may have cached the css.&lt;br /&gt;
&lt;br /&gt;
=== Update the xml and the zip file  ===&lt;br /&gt;
&lt;br /&gt;
Now we have to add the new files to the xml file and create an updated installation zip file.&lt;br /&gt;
&lt;br /&gt;
Add the helper.php and the special media tag to the xml file.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add helper.php ====&lt;br /&gt;
&lt;br /&gt;
Add helper.php to the files tag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;files&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;helper.php&amp;lt;/filename&amp;gt; &lt;br /&gt;
		&amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add media folder ====&lt;br /&gt;
&lt;br /&gt;
Add the media tag between files and languages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
	&amp;lt;media destination=&amp;quot;mod_yourmodule&amp;quot; folder=&amp;quot;media&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;css&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;images&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;js&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/media&amp;gt;&lt;br /&gt;
	&amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== Create the installation file ===&lt;br /&gt;
&lt;br /&gt;
Now you copy &#039;&#039;&#039;all&#039;&#039;&#039; module files from the server to the path &#039;somewhere&#039;/j_module_tutorial/new_module as in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
Create a new folder &#039;media&#039; and copy the three folders from media/mod_yourmodule.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  .../new_module&lt;br /&gt;
      /langs&lt;br /&gt;
        en-GB.mod_yourmodule.ini&lt;br /&gt;
        en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        anyother-language.mod_yourmodule.in&lt;br /&gt;
        anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /language&lt;br /&gt;
        /en-GB&lt;br /&gt;
          en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        /anyother-language&lt;br /&gt;
          anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /media&lt;br /&gt;
        /css&lt;br /&gt;
          yourmodule.css&lt;br /&gt;
        /images&lt;br /&gt;
          doc.png&lt;br /&gt;
          yourmodule-logo.png&lt;br /&gt;
        /js&lt;br /&gt;
          yourmodule.js&lt;br /&gt;
      /tmpl&lt;br /&gt;
        default.php&lt;br /&gt;
      mod_yourmodule.php&lt;br /&gt;
      mod_yourmodule.xml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the compressed installation zip file as described in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this tutorial. Below we describe an alternative for data retrieval.&lt;br /&gt;
&lt;br /&gt;
=== Use a component for data retrieval ===&lt;br /&gt;
&lt;br /&gt;
Below is an alternative to using direct sql. You can use the methods provided by a component to retrieve the data. If you develop your own component, you can prepare methods for reuse, otherwise you can try to find a method in a components models to retrieve the data you want. Here we reuse the getItem method of the content component ( articles ). In this case you get all article data returned. If you use a lot of modules of this type on the same page, be a little aware of momory usage. If you want to test it, you only have to replace the getData method in helper.php.&lt;br /&gt;
&lt;br /&gt;
To see the data available you can uncomment the var_dump line in mod_yourmodule.php.&lt;br /&gt;
&lt;br /&gt;
==== helper.php Use of component ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model = JModelLegacy::getInstance(&#039;Article&#039;, &#039;ContentModel&#039;, array(&#039;ignore_request&#039; =&amp;gt; true));&lt;br /&gt;
&lt;br /&gt;
		$app = JFactory::getApplication(&#039;site&#039;);&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;article.id&#039;, $id);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;list.offset&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
		// Load the parameters.&lt;br /&gt;
		$params = $app-&amp;gt;getParams(&#039;com_content&#039;);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;params&#039;, $params);&lt;br /&gt;
&lt;br /&gt;
		$user = JFactory::getUser();&lt;br /&gt;
&lt;br /&gt;
		if ((!$user-&amp;gt;authorise(&#039;core.edit.state&#039;, &#039;com_content&#039;)) &amp;amp;&amp;amp; (!$user-&amp;gt;authorise(&#039;core.edit&#039;, &#039;com_content&#039;)))&lt;br /&gt;
		{&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.published&#039;, 1);&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.archived&#039;, 2);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;filter.language&#039;, JLanguageMultilang::isEnabled());&lt;br /&gt;
  		&lt;br /&gt;
 		return $model-&amp;gt;getItem($id);;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add javascript to the module ===&lt;br /&gt;
&lt;br /&gt;
If you want to use javascript for yourmodule, here is an example. It loads the javascript file in the media/mod_yourmodule/js path and adds a script to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
Read more [[J3.x:Javascript_Frameworks|J3.x:Javascript Frameworks]]&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
   $document = JFactory::getDocument();&lt;br /&gt;
   $document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this code below the line that loads the css file if you want to test it.&lt;br /&gt;
&lt;br /&gt;
* We use jQuery so we have to load it &#039;&#039;&#039;before&#039;&#039;&#039; our own modules script. Here we load the Bootstrap framework that also includes jQuery. Use JHtml::_(&#039;jquery.framework&#039;) if you only need this.&lt;br /&gt;
* We add our scriptfile &amp;quot;relative&amp;quot; to the media folder.&lt;br /&gt;
* We add the script declaration directly to the document object. It gets added to the header in the html document.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Basic&amp;diff=125313</id>
		<title>User:Over/Step by step to a Joomla Module - Basic</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Basic&amp;diff=125313"/>
		<updated>2014-09-10T15:07:37Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Prepare files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you&lt;br /&gt;
&lt;br /&gt;
* have some interest in understanding the Joomla! Cms a little under the hood.&lt;br /&gt;
* are new to Joomla and want to be able to modify your site more than per option settings.&lt;br /&gt;
* have knowledge in web development but not with the Joomla! Cms&lt;br /&gt;
&lt;br /&gt;
this is something for you.&lt;br /&gt;
&lt;br /&gt;
{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
The first step will show you how to get your own custom module running in just a few minutes. Well, you have of course to subtract the time it takes to read and follow this text from the total time.&lt;br /&gt;
&lt;br /&gt;
If you run into problems, you can´t solve yourself, ask on the various Joomla developer communication channels.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
Before we start, some words about the requirements. You need access to a system with version 3.x of Joomla! installed. This with a web server - PHP, MySQL and Apache ( or a Microsoft IIS server ). A very good idea is to install a server on your local system. It will allow you to test any future changes, before you implement it on your live server. You can find documentation and hints how to do that by searching the www for Joomla and WAMP, LAMP, XAMPP, MAMP ...&lt;br /&gt;
&lt;br /&gt;
Example, without preference, from the Joomla! Community Magazine [http://magazine.joomla.org/issues/issue-mar-2013/item/1110-free-e-book-%E2%80%93-introducing-joomla-30-made-easy Installing Joomla 3.0 on local host using XAMPP] There are many users that find MAMP for Mac or WAMP for Windows easier to install and run.&lt;br /&gt;
&lt;br /&gt;
For the coding you need an editor. If you plan to develop in a larger scale you probably want to use an IDE, integrated development enviroment, or already have one. You can find information on alternatives elsewhere. If you only want to follow this tutorial and later make some minor changes (overrides) you can use a simpler editor. Search one for your local system. For Windows is Notepad++ an example. IMPORTANT! The Editor must be able to save the files with Unix type end of line (EOL) and character set UTF-8 w/o BOM (without byte order mark). You have to set this in the settings of the editor you use. This is a Joomla! requirement and may leave you with some surprises, if you don&#039;t follow it.&lt;br /&gt;
&lt;br /&gt;
[[Setting_up_your_workstation_for_Joomla_development|More technical documentation]]&lt;br /&gt;
&lt;br /&gt;
=== Prepare files ===&lt;br /&gt;
&lt;br /&gt;
Be sure that you have set error reporting to Development on your development system. {{rarr|System,Global,Server Settings,Error Reporting}} -&amp;gt; Development. Always None on a live system.&lt;br /&gt;
&lt;br /&gt;
OK! If you now have got it all together, let&#039;s start. There are some zipped files available. We&#039;ll use them as skeletons for the code we create. Download [http://github.com/schnuti/module-tutorial/zipball/master/ !!! replace with Joomla download !!!] to a new folder you can easily find. e.g. &#039;somewhere&#039;/j3_module_tutorial. Unzip it. As we are in the mood of creating folders add another subfolder e.g. &#039;somewhere&#039;/j3_module_tutorial/new_module. We will use that in a next tutorial to create the installation file for your module.&lt;br /&gt;
&lt;br /&gt;
Something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/&#039;somewhere&#039;&lt;br /&gt;
  /j3_module_tutorial        *new directory*&lt;br /&gt;
    /&#039;unpacked zip&#039;      &lt;br /&gt;
      ...                    *the files*&lt;br /&gt;
  /new_module                *new directory*&lt;br /&gt;
    ...                      *your own module files*&lt;br /&gt;
  downloaded.zip          &lt;br /&gt;
  mod_yourmodule_x_y_z.zip   *created during tutorial*&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should choose another name for your custom module. Development in a FOSS enviroment, free open source software, is not much about entering code. You use available code, copy/paste and make some modifications. At the end of this tutorial you&#039;ll have your own module, that you can use as &amp;quot;framework&amp;quot; for your next &amp;quot;module idea&amp;quot;. You only have to replace the name you gave the module with a new name.  We&#039;ll use &amp;quot;Yourmodule&amp;quot; throughout the tutorial. Always substitute this with your chosen name! Most of the times you have to use lower case as now with the directories and filenames. You do not have to understand every detail of the code lines. Just copy/paste and change the module name. You can for sure find deeper information about your special interests in web development in other sources. &lt;br /&gt;
&lt;br /&gt;
Look up the Joomla! root directory on your test system. It depends on your server and Joomla! installation. For Wamp it might be c:\wamp\www\joomla. For XAMPP c:\xampp\htdocs\joomla. Here you&#039;ll find a modules directory where you create a subdirectory mod_yourmodule. Don&#039;t forget to use your own name! We also need a mod_yourmodule/tmpl directory.&lt;br /&gt;
&lt;br /&gt;
In this step we&#039;ll only use 3 files. mod_yourmodule.xml - the so called manifest file that controls the installation and in the module case holds any configuration options, mod_yourmodule.php is the start up file / entry point. default.php holds the code for output. The latter can be named otherwise and is also called template or layout. Somewhat confusing as template and layout is used also in other contexts.&lt;br /&gt;
&lt;br /&gt;
Now you copy mod_yourmodule.xml and mod_yourmodule.php to your path/to/joomla/modules/mod_yourmodule directory. Rename! You copy default.php to path/to/joomla/modules/mod_yourmodule/tmpl.&lt;br /&gt;
&lt;br /&gt;
After you created the 2 new directories and copied the 3 new files your Joomla path should look like below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/media&lt;br /&gt;
/modules&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /tmpl                  *new directory*&lt;br /&gt;
      default.php          *new file*&lt;br /&gt;
    mod_yourmodule.php     *new file*&lt;br /&gt;
    mod_yourmodule.xml     *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/plugins&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The modules xml file ===&lt;br /&gt;
&lt;br /&gt;
Open mod_yourmodule.xml with your editor. We&#039;ll have a look at what we have there and make some modifications.&lt;br /&gt;
&lt;br /&gt;
More information about [[Manifest_files|Manifest files]]. We will come back to this file more than once to add more tags and definitions.&lt;br /&gt;
&lt;br /&gt;
===== mod_yourmodule.xml =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;module&amp;quot; version=&amp;quot;3.3.0&amp;quot; client=&amp;quot;site&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;name&amp;gt;mod_yourmodule&amp;lt;/name&amp;gt;&lt;br /&gt;
    &amp;lt;version&amp;gt;1.0.0&amp;lt;/version&amp;gt;&lt;br /&gt;
	&amp;lt;creationDate&amp;gt;August 2014&amp;lt;/creationDate&amp;gt;&lt;br /&gt;
    &amp;lt;author&amp;gt;Joomla Doe&amp;lt;/author&amp;gt;&lt;br /&gt;
	&amp;lt;authorUrl&amp;gt;www.yourmodule.org&amp;lt;/authorUrl&amp;gt;&lt;br /&gt;
 	&amp;lt;authorEmail&amp;gt;joomla.doe@yourmodule.org&amp;lt;/authorEmail&amp;gt;&lt;br /&gt;
	&amp;lt;copyright&amp;gt;Copyright (C) 2014 Joomla Doe&amp;lt;/copyright&amp;gt;&lt;br /&gt;
	&amp;lt;license&amp;gt;GNU General Public License version 2 or later; see LICENSE.txt&amp;lt;/license&amp;gt;&lt;br /&gt;
    &amp;lt;description&amp;gt;Your own first custom module.&amp;lt;/description&amp;gt;&lt;br /&gt;
    &amp;lt;files&amp;gt;&lt;br /&gt;
        &amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
        &amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
        &amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
    &amp;lt;/files&amp;gt;&lt;br /&gt;
    &amp;lt;config&amp;gt;&lt;br /&gt;
    &amp;lt;/config&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The content of the xml file is almost self explaining. We define the extension as a module for Joomla! versions 3.3.0 and above. 3.3.3 is the latest version at the time of creating the tutorial Upgrade means that we leave to the installer program to decide, if it is a new installation or an update/upgrade. The name, the version and the date of the extension. Be extra careful with the module name. Any errors will stop the installation. We use mod_yourmodule as name and will come back to the reason in a later part. Information about the author with contact data. Copyright and license. If the module will be for your own private use only, you don&#039;t need all of it. It is however a good practice to include it.&lt;br /&gt;
&lt;br /&gt;
In the description you obviously explain what the module is supposed to do.&lt;br /&gt;
&lt;br /&gt;
In the files part you define what files and folders are included in your module. folder has the effect that all included files will be copied from your packed installation file to that directory (=folder). You don&#039;t have to include mod_yourmodule.xml here as it always will be copied.&lt;br /&gt;
&lt;br /&gt;
Comment: We did not include any index.html files. These were used to prevent users to attempt to list the content by pointing their browser to these folders. Joomla! has dropped this requirement. Acces is blocked by your .htaccess / web.config file if properly set up. The default of those files include the needed settings.&lt;br /&gt;
&lt;br /&gt;
We&#039;ll come back to &amp;amp;lt;config&amp;amp;gt; when we extend the functionality. It stays empty for now.&lt;br /&gt;
&lt;br /&gt;
Edit this file and replace the data with your own name/modulename.&lt;br /&gt;
&lt;br /&gt;
Save and close mod_yourmodule.xml&lt;br /&gt;
&lt;br /&gt;
=== The start up file ===&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll have a look at the entry point file mod_yourmodule.php.&lt;br /&gt;
&lt;br /&gt;
===== mod_yourmodule.php =====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
require JModuleHelper::getLayoutPath(&#039;mod_yourmodule&#039;, $params-&amp;gt;get(&#039;layout&#039;, &#039;default&#039;));&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Not more than this is needed for the most basic module we develop in this first tutorial part.&lt;br /&gt;
&lt;br /&gt;
You tell the system that this is php code and write a comment. You can find example comments in any Joomla! core php file or any 3.d party extension. You can add more information if you like but do not overdo. If you use functionality from another developers in the code it&#039;s a nice practice to mention that. Something like : this is a fork of mod_yourmodule by Joomla Doe. &lt;br /&gt;
&lt;br /&gt;
The line defined(... has to be included! It prevents users from running this php code from outside of Joomla!.&lt;br /&gt;
&lt;br /&gt;
The last line calls the default.php file that includes the output commands ( name without php ending ). You can see that the confusing word layout is used. Here it means a file in the tmpl folder.&lt;br /&gt;
&lt;br /&gt;
{{Tip|Do not add a php closing tag &#039; ?&amp;gt;&#039; at the end of a php file. Add an empty line at the end of files.}}&lt;br /&gt;
&lt;br /&gt;
Edit the module name and save. Do not close it if your editor allows to hold two or more files open.&lt;br /&gt;
&lt;br /&gt;
If you want to know more about Joomla! coding standards: [http://joomla.github.io/coding-standards/ joomla coding-standards] Contibutions to Joomla! core development must follow those standards.&lt;br /&gt;
&lt;br /&gt;
More for advanced developers: [[Joomla_CodeSniffer|Joomla CodeSniffer]] and [https://github.com/joomla/coding-standards/tree/master/IDE joomla/ coding-standards - IDE]&lt;br /&gt;
&lt;br /&gt;
=== The output/template/layout file ===&lt;br /&gt;
&lt;br /&gt;
The last file to edit before we enable the module for the frontend pages is the default.php&lt;br /&gt;
&lt;br /&gt;
===== default.php =====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;From your first module&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;This is the content&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the comments part - that you changed - from the former php file and paste it here, replacing the comment. After the obligatory defined(... line we close the php part with ?&amp;gt;. The rest is at your disposal. Use the knowledge you have of html code to show text on the frontpage. Alternatively you can write a very short article in the Joomla! backend, toggle the editor and copy the source code to the php file. If you do, save the article and note the article. We&#039;ll use an article as source in a later step.&lt;br /&gt;
&lt;br /&gt;
After saving the file we are ready to enable your custom module on the frontend.&lt;br /&gt;
&lt;br /&gt;
=== Install and enable the module ===&lt;br /&gt;
&lt;br /&gt;
{{Tip|Before you proceed it might be a good idea to backup your test site. Well, only in case of ...}}&lt;br /&gt;
The most simple way to backup your local server is to copy the whole web directory. It includes both your local site and the database. See path examples above. &lt;br /&gt;
&lt;br /&gt;
We do not need to create a compressed installation file (.zip) to install an extension. We&#039;ll use the Discover method.&lt;br /&gt;
&lt;br /&gt;
Go to {{rarr|Extensions,Extension Manager,Click on Discover}}, in the Extension Manager:Discover menu you click on the Discover button&lt;br /&gt;
&lt;br /&gt;
Mark your module in the list and click on the Install button. If everything went well, you&#039;ll get a message that tells you that the module was installed.&lt;br /&gt;
&lt;br /&gt;
At last you enable the module in the Module Manager. Click on New and find it in the the list. As difference to &amp;quot;normal&amp;quot; module installation the Discover method probably did not add an entry to the module instances list. The name is mod_yourmodule so you&#039;ll find it lower case sorted to the end of the list . We&#039;ll fix that in the next tutorial part.&lt;br /&gt;
&lt;br /&gt;
Info for new Joomla! users: You can create multiple instances/copies of a module. Each with different option settings. That is what you do when you click on the New button.&lt;br /&gt;
&lt;br /&gt;
Add a title, choose a module position and publish. Go to the frontend and see your first module creation. You can now modify the default.php file to get something fancy before you go on to the next step in the tutorial.&lt;br /&gt;
&lt;br /&gt;
{{Tip|To remember for ever. Do not forget to click the Menu Assignment tab in the Module Manager. Promised: You will! }}&lt;br /&gt;
&lt;br /&gt;
More about [[Module|Joomla! Modules]]&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Advanced_installation&amp;diff=125270</id>
		<title>User:Over/Step by step to a Joomla Module - Advanced installation</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Advanced_installation&amp;diff=125270"/>
		<updated>2014-09-09T10:13:51Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Add a table for the module */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we add the advanced installation possibilities &#039;Installation script&#039;, &#039;Update server&#039; and &#039;Table creation&#039;. You should have some deeper knowledge of Php or follow the [[J3.x:Developing_a_MVC_Component/Introduction|J3.x:Developing a MVC Component/Introduction]] before adding those to your module.&lt;br /&gt;
&lt;br /&gt;
=== Installation script ===&lt;br /&gt;
&lt;br /&gt;
You can find a script.php in the downloaded tutorial zip file. It includes the same methods as installation scripts for components and other extensions. It lets you add extra functionality. You can use another name for this file. As an example - you can create a folder in images/ and copy some default images to this new folder.  &lt;br /&gt;
&lt;br /&gt;
* install      : executes when extension gets installed&lt;br /&gt;
* uninstall    : executes when extension gets uninstalled&lt;br /&gt;
* update       : executes when extension gets updated&lt;br /&gt;
* preflight    : executes before install/uninstall/update&lt;br /&gt;
* postflight   : executes after install/update&lt;br /&gt;
&lt;br /&gt;
You add it to the xml file with&lt;br /&gt;
==== mod_yourmodule.xml Installation script ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
	&amp;lt;!-- Runs on install/uninstall/update --&amp;gt;&lt;br /&gt;
	&amp;lt;scriptfile&amp;gt;script.php&amp;lt;/scriptfile&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You of course add the physical file to the folder you use to create the zip installation file.&lt;br /&gt;
&lt;br /&gt;
=== Update server ===&lt;br /&gt;
&lt;br /&gt;
If you publish your module to other users as on the JED [http://extensions.joomla.org/ extensions.joomla.org/], it&#039;s recommended that you supply automatic updates on a server of your choise. Here we only show you one example of the code in the xml file. Please read more here [[Deploying_an_Update_Server|Deploying an update server]] &lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml Update server ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
   &amp;lt;updateservers&amp;gt;&lt;br /&gt;
      &amp;lt;server type=&amp;quot;extension&amp;quot; priority=&amp;quot;1&amp;quot; name=&amp;quot;Your Module Update Site&amp;quot;&amp;gt;http://www.myserver.xy/updates/yourmodule.xml&amp;lt;/server&amp;gt;&lt;br /&gt;
	&amp;lt;/updateservers&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the update information at the bottom of the xml file. In addition you have to add the xml and update zip files on the update server. An example xml is included in the tutorial example data. The zip file is the latest of the installation zip of your module.&lt;br /&gt;
&lt;br /&gt;
=== Add a table for the module ===&lt;br /&gt;
&lt;br /&gt;
You should consider a small backend component as soon as you want to use a table with your module. You shouldn&#039;t force users to maintain the table with a database tool. It is realy easy to create a single list view to allow the user to see the entries and delete any unwanted entries. You can also provide methods to retrieve and store the data from the module.&lt;br /&gt;
Just follow the component tutorial. The use of a component for data retrieval was explaind in another part of this tutorial.&lt;br /&gt;
&lt;br /&gt;
In case you have reasons not to provide a component, we add some tips here.&lt;br /&gt;
&lt;br /&gt;
You can find a sql folder in the zip file you downloaded. Copy this to your modules &#039;root&#039; folder where you create the installation zip file. You have to include this for the new installation. It&#039;s hard to install and update a database table if the code wasn&#039;t executad at installation. Any update sql file is additionaly executed at new installation.&lt;br /&gt;
{{Tip|You have to supply an empty update sql file for your first version!}}&lt;br /&gt;
&lt;br /&gt;
This example only includes the MySql database.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/media&lt;br /&gt;
/sql                       *new directory*&lt;br /&gt;
   /updates                *new directory*&lt;br /&gt;
      /mysql               *new directory*&lt;br /&gt;
         1.0.0.sql         *new file*&lt;br /&gt;
   install.mysql.sql       *new file*&lt;br /&gt;
   uninstall.mysql.sql     *new file*&lt;br /&gt;
/tmpl&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In install.mysql.sql you create the table(s).&lt;br /&gt;
* In uninstall.mysql.sql you delete the table(s).&lt;br /&gt;
* In the folder /updates/mysql you add the empty sql with a version number. The version number has no relation to the modules number! It&#039;s up to you. Here 1.0.0.sql&lt;br /&gt;
* In the folder /updates/mysql you add updates to the table(s). Increase the version number. The next would in this case be 1.0.1.sql&lt;br /&gt;
&lt;br /&gt;
Include the sql in the xml file.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml Include the sql ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;files&amp;gt;&lt;br /&gt;
      ...&lt;br /&gt;
      &amp;lt;folder&amp;gt;sql&amp;lt;/folder&amp;gt;&lt;br /&gt;
   &amp;lt;/files&amp;gt;&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
   &amp;lt;/languages&amp;gt;&lt;br /&gt;
   &amp;lt;install&amp;gt;&lt;br /&gt;
      &amp;lt;sql&amp;gt;&lt;br /&gt;
         &amp;lt;file charset=&amp;quot;utf8&amp;quot; driver=&amp;quot;mysql&amp;quot;&amp;gt;sql/install.mysql.sql&amp;lt;/file&amp;gt;&lt;br /&gt;
      &amp;lt;/sql&amp;gt;&lt;br /&gt;
   &amp;lt;/install&amp;gt;&lt;br /&gt;
   &amp;lt;uninstall&amp;gt;&lt;br /&gt;
      &amp;lt;sql&amp;gt;&lt;br /&gt;
         &amp;lt;file charset=&amp;quot;utf8&amp;quot; driver=&amp;quot;mysql&amp;quot;&amp;gt;sql/uninstall.mysql.sql&amp;lt;/file&amp;gt;&lt;br /&gt;
      &amp;lt;/sql&amp;gt;&lt;br /&gt;
   &amp;lt;/uninstall&amp;gt;&lt;br /&gt;
   &amp;lt;update&amp;gt;&lt;br /&gt;
      &amp;lt;schemas&amp;gt;&lt;br /&gt;
         &amp;lt;schemapath type=&amp;quot;mysql&amp;quot;&amp;gt;sql/updates/mysql&amp;lt;/schemapath&amp;gt;&lt;br /&gt;
      &amp;lt;/schemas&amp;gt;&lt;br /&gt;
   &amp;lt;/update&amp;gt;&lt;br /&gt;
   &amp;lt;config&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Edit the install.mysql.sql and the uninstall.mysql.sql with your table definitions. &lt;br /&gt;
* Add the sql folder to the files tag and the install, uninstall, update tags as above.&lt;br /&gt;
* Create the installation zip file.&lt;br /&gt;
* Uninstall the module if it is previously installed.&lt;br /&gt;
* Install with the new installation file.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Advanced_installation&amp;diff=125269</id>
		<title>User:Over/Step by step to a Joomla Module - Advanced installation</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Advanced_installation&amp;diff=125269"/>
		<updated>2014-09-09T10:12:35Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Update server */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we add the advanced installation possibilities &#039;Installation script&#039;, &#039;Update server&#039; and &#039;Table creation&#039;. You should have some deeper knowledge of Php or follow the [[J3.x:Developing_a_MVC_Component/Introduction|J3.x:Developing a MVC Component/Introduction]] before adding those to your module.&lt;br /&gt;
&lt;br /&gt;
=== Installation script ===&lt;br /&gt;
&lt;br /&gt;
You can find a script.php in the downloaded tutorial zip file. It includes the same methods as installation scripts for components and other extensions. It lets you add extra functionality. You can use another name for this file. As an example - you can create a folder in images/ and copy some default images to this new folder.  &lt;br /&gt;
&lt;br /&gt;
* install      : executes when extension gets installed&lt;br /&gt;
* uninstall    : executes when extension gets uninstalled&lt;br /&gt;
* update       : executes when extension gets updated&lt;br /&gt;
* preflight    : executes before install/uninstall/update&lt;br /&gt;
* postflight   : executes after install/update&lt;br /&gt;
&lt;br /&gt;
You add it to the xml file with&lt;br /&gt;
==== mod_yourmodule.xml Installation script ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
	&amp;lt;!-- Runs on install/uninstall/update --&amp;gt;&lt;br /&gt;
	&amp;lt;scriptfile&amp;gt;script.php&amp;lt;/scriptfile&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You of course add the physical file to the folder you use to create the zip installation file.&lt;br /&gt;
&lt;br /&gt;
=== Update server ===&lt;br /&gt;
&lt;br /&gt;
If you publish your module to other users as on the JED [http://extensions.joomla.org/ extensions.joomla.org/], it&#039;s recommended that you supply automatic updates on a server of your choise. Here we only show you one example of the code in the xml file. Please read more here [[Deploying_an_Update_Server|Deploying an update server]] &lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml Update server ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
   &amp;lt;updateservers&amp;gt;&lt;br /&gt;
      &amp;lt;server type=&amp;quot;extension&amp;quot; priority=&amp;quot;1&amp;quot; name=&amp;quot;Your Module Update Site&amp;quot;&amp;gt;http://www.myserver.xy/updates/yourmodule.xml&amp;lt;/server&amp;gt;&lt;br /&gt;
	&amp;lt;/updateservers&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the update information at the bottom of the xml file. In addition you have to add the xml and update zip files on the update server. An example xml is included in the tutorial example data. The zip file is the latest of the installation zip of your module.&lt;br /&gt;
&lt;br /&gt;
=== Add a table for the module ===&lt;br /&gt;
&lt;br /&gt;
You should consider a small backend component as soon as you want to use a table with your module. You shouldn&#039;t force users to maintain the table with a database tool. It is realy easy to create a single list view to allow the user to see the entries and delete any unwanted entries. You can also provide methods to retrive and store the data from the module.&lt;br /&gt;
Just follow the component tutorial. The use of a component for data retrieval was explaind in another part of this tutorial.&lt;br /&gt;
&lt;br /&gt;
In case you have reasons not to provide a component, we add some tips here.&lt;br /&gt;
&lt;br /&gt;
You can find a sql folder in the zip file you downloaded. Copy this to your modules &#039;root&#039; folder where you create the installation zip file. You have to include this for the new installation. It&#039;s hard to install and update a database table if the code wasn&#039;t executad at installation. Any update sql file is additionaly executed at new installation.&lt;br /&gt;
{{Tip|You have to supply an empty update sql file for your first version!}}&lt;br /&gt;
&lt;br /&gt;
This example only includes the MySql database.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/media&lt;br /&gt;
/sql                       *new directory*&lt;br /&gt;
   /updates                *new directory*&lt;br /&gt;
      /mysql               *new directory*&lt;br /&gt;
         1.0.0.sql         *new file*&lt;br /&gt;
   install.mysql.sql       *new file*&lt;br /&gt;
   uninstall.mysql.sql     *new file*&lt;br /&gt;
/tmpl&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In install.mysql.sql you create the table(s).&lt;br /&gt;
* In uninstall.mysql.sql you delete the table(s).&lt;br /&gt;
* In the folder /updates/mysql you add the empty sql with a version number. The version number has no relation to the modules number! It&#039;s up to you. Here 1.0.0.sql&lt;br /&gt;
* In the folder /updates/mysql you add updates to the table(s). Increase the version number. The next would in this case be 1.0.1.sql&lt;br /&gt;
&lt;br /&gt;
Include the sql in the xml file.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml Include the sql ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;files&amp;gt;&lt;br /&gt;
      ...&lt;br /&gt;
      &amp;lt;folder&amp;gt;sql&amp;lt;/folder&amp;gt;&lt;br /&gt;
   &amp;lt;/files&amp;gt;&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
   &amp;lt;/languages&amp;gt;&lt;br /&gt;
   &amp;lt;install&amp;gt;&lt;br /&gt;
      &amp;lt;sql&amp;gt;&lt;br /&gt;
         &amp;lt;file charset=&amp;quot;utf8&amp;quot; driver=&amp;quot;mysql&amp;quot;&amp;gt;sql/install.mysql.sql&amp;lt;/file&amp;gt;&lt;br /&gt;
      &amp;lt;/sql&amp;gt;&lt;br /&gt;
   &amp;lt;/install&amp;gt;&lt;br /&gt;
   &amp;lt;uninstall&amp;gt;&lt;br /&gt;
      &amp;lt;sql&amp;gt;&lt;br /&gt;
         &amp;lt;file charset=&amp;quot;utf8&amp;quot; driver=&amp;quot;mysql&amp;quot;&amp;gt;sql/uninstall.mysql.sql&amp;lt;/file&amp;gt;&lt;br /&gt;
      &amp;lt;/sql&amp;gt;&lt;br /&gt;
   &amp;lt;/uninstall&amp;gt;&lt;br /&gt;
   &amp;lt;update&amp;gt;&lt;br /&gt;
      &amp;lt;schemas&amp;gt;&lt;br /&gt;
         &amp;lt;schemapath type=&amp;quot;mysql&amp;quot;&amp;gt;sql/updates/mysql&amp;lt;/schemapath&amp;gt;&lt;br /&gt;
      &amp;lt;/schemas&amp;gt;&lt;br /&gt;
   &amp;lt;/update&amp;gt;&lt;br /&gt;
   &amp;lt;config&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Edit the install.mysql.sql and the uninstall.mysql.sql with your table definitions. &lt;br /&gt;
* Add the sql folder to the files tag and the install, uninstall, update tags as above.&lt;br /&gt;
* Create the installation zip file.&lt;br /&gt;
* Uninstall the module if it is previously installed.&lt;br /&gt;
* Install with the new installation file.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Advanced_installation&amp;diff=125268</id>
		<title>User:Over/Step by step to a Joomla Module - Advanced installation</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Advanced_installation&amp;diff=125268"/>
		<updated>2014-09-09T10:03:53Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we add the advanced installation possibilities &#039;Installation script&#039;, &#039;Update server&#039; and &#039;Table creation&#039;. You should have some deeper knowledge of Php or follow the [[J3.x:Developing_a_MVC_Component/Introduction|J3.x:Developing a MVC Component/Introduction]] before adding those to your module.&lt;br /&gt;
&lt;br /&gt;
=== Installation script ===&lt;br /&gt;
&lt;br /&gt;
You can find a script.php in the downloaded tutorial zip file. It includes the same methods as installation scripts for components and other extensions. It lets you add extra functionality. You can use another name for this file. As an example - you can create a folder in images/ and copy some default images to this new folder.  &lt;br /&gt;
&lt;br /&gt;
* install      : executes when extension gets installed&lt;br /&gt;
* uninstall    : executes when extension gets uninstalled&lt;br /&gt;
* update       : executes when extension gets updated&lt;br /&gt;
* preflight    : executes before install/uninstall/update&lt;br /&gt;
* postflight   : executes after install/update&lt;br /&gt;
&lt;br /&gt;
You add it to the xml file with&lt;br /&gt;
==== mod_yourmodule.xml Installation script ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
	&amp;lt;!-- Runs on install/uninstall/update --&amp;gt;&lt;br /&gt;
	&amp;lt;scriptfile&amp;gt;script.php&amp;lt;/scriptfile&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You of course add the physical file to the folder you use to create the zip installation file.&lt;br /&gt;
&lt;br /&gt;
=== Update server ===&lt;br /&gt;
&lt;br /&gt;
If you publish your module to other users as on the JED [http://extensions.joomla.org/ extensions.joomla.org/], it&#039;s recommended that you supply automatic updates on a server of your choise. Here we only show you one example of the code in the xml file. Please read more here [[Deploying_an_Update_Server|Deploying an update server]] &lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml Update server ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
   ...&lt;br /&gt;
   &amp;lt;updateservers&amp;gt;&lt;br /&gt;
      &amp;lt;server type=&amp;quot;extension&amp;quot; priority=&amp;quot;1&amp;quot; name=&amp;quot;Your Module Update Site&amp;quot;&amp;gt;http://www.myserver.xy/updates/yourmodule.xml&amp;lt;/server&amp;gt;&lt;br /&gt;
	&amp;lt;/updateservers&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the update information at the bottom of the xml file. In addition you have to create the xml and update files on the server.&lt;br /&gt;
&lt;br /&gt;
=== Add a table for the module ===&lt;br /&gt;
&lt;br /&gt;
You should consider a small backend component as soon as you want to use a table with your module. You shouldn&#039;t force users to maintain the table with a database tool. It is realy easy to create a single list view to allow the user to see the entries and delete any unwanted entries. You can also provide methods to retrive and store the data from the module.&lt;br /&gt;
Just follow the component tutorial. The use of a component for data retrieval was explaind in another part of this tutorial.&lt;br /&gt;
&lt;br /&gt;
In case you have reasons not to provide a component, we add some tips here.&lt;br /&gt;
&lt;br /&gt;
You can find a sql folder in the zip file you downloaded. Copy this to your modules &#039;root&#039; folder where you create the installation zip file. You have to include this for the new installation. It&#039;s hard to install and update a database table if the code wasn&#039;t executad at installation. Any update sql file is additionaly executed at new installation.&lt;br /&gt;
{{Tip|You have to supply an empty update sql file for your first version!}}&lt;br /&gt;
&lt;br /&gt;
This example only includes the MySql database.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/media&lt;br /&gt;
/sql                       *new directory*&lt;br /&gt;
   /updates                *new directory*&lt;br /&gt;
      /mysql               *new directory*&lt;br /&gt;
         1.0.0.sql         *new file*&lt;br /&gt;
   install.mysql.sql       *new file*&lt;br /&gt;
   uninstall.mysql.sql     *new file*&lt;br /&gt;
/tmpl&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In install.mysql.sql you create the table(s).&lt;br /&gt;
* In uninstall.mysql.sql you delete the table(s).&lt;br /&gt;
* In the folder /updates/mysql you add the empty sql with a version number. The version number has no relation to the modules number! It&#039;s up to you. Here 1.0.0.sql&lt;br /&gt;
* In the folder /updates/mysql you add updates to the table(s). Increase the version number. The next would in this case be 1.0.1.sql&lt;br /&gt;
&lt;br /&gt;
Include the sql in the xml file.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml Include the sql ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;files&amp;gt;&lt;br /&gt;
      ...&lt;br /&gt;
      &amp;lt;folder&amp;gt;sql&amp;lt;/folder&amp;gt;&lt;br /&gt;
   &amp;lt;/files&amp;gt;&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
     ...&lt;br /&gt;
   &amp;lt;/languages&amp;gt;&lt;br /&gt;
   &amp;lt;install&amp;gt;&lt;br /&gt;
      &amp;lt;sql&amp;gt;&lt;br /&gt;
         &amp;lt;file charset=&amp;quot;utf8&amp;quot; driver=&amp;quot;mysql&amp;quot;&amp;gt;sql/install.mysql.sql&amp;lt;/file&amp;gt;&lt;br /&gt;
      &amp;lt;/sql&amp;gt;&lt;br /&gt;
   &amp;lt;/install&amp;gt;&lt;br /&gt;
   &amp;lt;uninstall&amp;gt;&lt;br /&gt;
      &amp;lt;sql&amp;gt;&lt;br /&gt;
         &amp;lt;file charset=&amp;quot;utf8&amp;quot; driver=&amp;quot;mysql&amp;quot;&amp;gt;sql/uninstall.mysql.sql&amp;lt;/file&amp;gt;&lt;br /&gt;
      &amp;lt;/sql&amp;gt;&lt;br /&gt;
   &amp;lt;/uninstall&amp;gt;&lt;br /&gt;
   &amp;lt;update&amp;gt;&lt;br /&gt;
      &amp;lt;schemas&amp;gt;&lt;br /&gt;
         &amp;lt;schemapath type=&amp;quot;mysql&amp;quot;&amp;gt;sql/updates/mysql&amp;lt;/schemapath&amp;gt;&lt;br /&gt;
      &amp;lt;/schemas&amp;gt;&lt;br /&gt;
   &amp;lt;/update&amp;gt;&lt;br /&gt;
   &amp;lt;config&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Edit the install.mysql.sql and the uninstall.mysql.sql with your table definitions. &lt;br /&gt;
* Add the sql folder to the files tag and the install, uninstall, update tags as above.&lt;br /&gt;
* Create the installation zip file.&lt;br /&gt;
* Uninstall the module if it is previously installed.&lt;br /&gt;
* Install with the new installation file.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Basic&amp;diff=125267</id>
		<title>User:Over/Step by step to a Joomla Module - Basic</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Basic&amp;diff=125267"/>
		<updated>2014-09-09T09:35:54Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Prepare files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you&lt;br /&gt;
&lt;br /&gt;
* have some interest in understanding the Joomla! Cms a little under the hood.&lt;br /&gt;
* are new to Joomla and want to be able to modify your site more than per option settings.&lt;br /&gt;
* have knowledge in web development but not with the Joomla! Cms&lt;br /&gt;
&lt;br /&gt;
this is something for you.&lt;br /&gt;
&lt;br /&gt;
{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
The first step will show you how to get your own custom module running in just a few minutes. Well, you have of course to subtract the time it takes to read and follow this text from the total time.&lt;br /&gt;
&lt;br /&gt;
If you run into problems, you can´t solve yourself, ask on the various Joomla developer communication channels.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
Before we start, some words about the requirements. You need access to a system with version 3.x of Joomla! installed. This with a web server - PHP, MySQL and Apache ( or a Microsoft IIS server ). A very good idea is to install a server on your local system. It will allow you to test any future changes, before you implement it on your live server. You can find documentation and hints how to do that by searching the www for Joomla and WAMP, LAMP, XAMPP, MAMP ...&lt;br /&gt;
&lt;br /&gt;
Example, without preference, from the Joomla! Community Magazine [http://magazine.joomla.org/issues/issue-mar-2013/item/1110-free-e-book-%E2%80%93-introducing-joomla-30-made-easy Installing Joomla 3.0 on local host using XAMPP] There are many users that find MAMP for Mac or WAMP for Windows easier to install and run.&lt;br /&gt;
&lt;br /&gt;
For the coding you need an editor. If you plan to develop in a larger scale you probably want to use an IDE, integrated development enviroment, or already have one. You can find information on alternatives elsewhere. If you only want to follow this tutorial and later make some minor changes (overrides) you can use a simpler editor. Search one for your local system. For Windows is Notepad++ an example. IMPORTANT! The Editor must be able to save the files with Unix type end of line (EOL) and character set UTF-8 w/o BOM (without byte order mark). You have to set this in the settings of the editor you use. This is a Joomla! requirement and may leave you with some surprises, if you don&#039;t follow it.&lt;br /&gt;
&lt;br /&gt;
[[Setting_up_your_workstation_for_Joomla_development|More technical documentation]]&lt;br /&gt;
&lt;br /&gt;
=== Prepare files ===&lt;br /&gt;
&lt;br /&gt;
Be sure that you have set error reporting to Development on your development system. {{rarr|System,Global,Server Settings,Error Reporting}} -&amp;gt; Development. Always None on a live system.&lt;br /&gt;
&lt;br /&gt;
OK! If you now have got it all together, let&#039;s start. There are some zipped files available. We&#039;ll use them as skeletons for the code we create. Download [http://github.com/schnuti/module-tutorial/zipball/master/ !!! replace with Joomla download !!!] to a new folder you can easily find. e.g. &#039;somewhere&#039;/j3_module_tutorial. Unzip it. As we are in the mood of creating folders add another subfolder e.g. &#039;somewhere&#039;/j3_module_tutorial/new_module. We will use that in a next tutorial to create the installation file for your module.&lt;br /&gt;
&lt;br /&gt;
Something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/&#039;somewhere&#039;&lt;br /&gt;
  /j3_module_tutorial        *new directory*&lt;br /&gt;
    /&#039;unpacked zip&#039;      &lt;br /&gt;
      ...                    *the files*&lt;br /&gt;
  /new_module                *new directory*&lt;br /&gt;
    ...                      *your own module files*&lt;br /&gt;
  downloaded.zip          &lt;br /&gt;
  mod_yourmodule_x_y_z.zip   *created during tutorial*&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should choose another name for your custom module. Development in a FOSS enviroment, free open source software, is not much about entering code. You use available code, copy/paste and make some modifications. At the end of this tutorial you&#039;ll have your own module, that you can use as &amp;quot;framework&amp;quot; for your next &amp;quot;module idea&amp;quot;. You only have to replace the name you gave the module with a new name.  We&#039;ll use &amp;quot;Yourmodule&amp;quot; throughout the tutorial. Always substitute this with your chosen name! Most of the times you have to use lower case as now with the directories and filenames. You do not have to understand every detail of the code lines. Just copy/paste and change the module name. You can for sure find deeper information about your special interests in web development. &lt;br /&gt;
&lt;br /&gt;
Look up the Joomla! root directory on your test system. It depends on your server and Joomla! installation. For Wamp it might be c:\wamp\www\joomla. For XAMPP c:\xampp\htdocs\joomla. Here you&#039;ll find a modules directory where you create a subdirectory mod_yourmodule. Don&#039;t forget to use your own name! We also need a mod_yourmodule/tmpl directory.&lt;br /&gt;
&lt;br /&gt;
In this step we&#039;ll only use 3 files. mod_yourmodule.xml - the so called manifest file that controls the installation and in the module case holds any configuration options, mod_yourmodule.php is the start up file / entry point. default.php holds the code for output. The latter can be named otherwise and is also called template or layout. Somewhat confusing as template and layout is used also in other contexts.&lt;br /&gt;
&lt;br /&gt;
Now you copy mod_yourmodule.xml and mod_yourmodule.php to your path/to/joomla/modules/mod_yourmodule directory. Rename! You copy default.php to path/to/joomla/modules/mod_yourmodule/tmpl.&lt;br /&gt;
&lt;br /&gt;
After you created the 2 new directories and copied the 3 new files your Joomla path should look like below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/media&lt;br /&gt;
/modules&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /tmpl                  *new directory*&lt;br /&gt;
      default.php          *new file*&lt;br /&gt;
    mod_yourmodule.php     *new file*&lt;br /&gt;
    mod_yourmodule.xml     *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/plugins&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The modules xml file ===&lt;br /&gt;
&lt;br /&gt;
Open mod_yourmodule.xml with your editor. We&#039;ll have a look at what we have there and make some modifications.&lt;br /&gt;
&lt;br /&gt;
More information about [[Manifest_files|Manifest files]]. We will come back to this file more than once to add more tags and definitions.&lt;br /&gt;
&lt;br /&gt;
===== mod_yourmodule.xml =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;module&amp;quot; version=&amp;quot;3.3.0&amp;quot; client=&amp;quot;site&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;name&amp;gt;mod_yourmodule&amp;lt;/name&amp;gt;&lt;br /&gt;
    &amp;lt;version&amp;gt;1.0.0&amp;lt;/version&amp;gt;&lt;br /&gt;
	&amp;lt;creationDate&amp;gt;August 2014&amp;lt;/creationDate&amp;gt;&lt;br /&gt;
    &amp;lt;author&amp;gt;Joomla Doe&amp;lt;/author&amp;gt;&lt;br /&gt;
	&amp;lt;authorUrl&amp;gt;www.yourmodule.org&amp;lt;/authorUrl&amp;gt;&lt;br /&gt;
 	&amp;lt;authorEmail&amp;gt;joomla.doe@yourmodule.org&amp;lt;/authorEmail&amp;gt;&lt;br /&gt;
	&amp;lt;copyright&amp;gt;Copyright (C) 2014 Joomla Doe&amp;lt;/copyright&amp;gt;&lt;br /&gt;
	&amp;lt;license&amp;gt;GNU General Public License version 2 or later; see LICENSE.txt&amp;lt;/license&amp;gt;&lt;br /&gt;
    &amp;lt;description&amp;gt;Your own first custom module.&amp;lt;/description&amp;gt;&lt;br /&gt;
    &amp;lt;files&amp;gt;&lt;br /&gt;
        &amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
        &amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
        &amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
    &amp;lt;/files&amp;gt;&lt;br /&gt;
    &amp;lt;config&amp;gt;&lt;br /&gt;
    &amp;lt;/config&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The content of the xml file is almost self explaining. We define the extension as a module for Joomla! versions 3.3.0 and above. 3.3.3 is the latest version at the time of creating the tutorial Upgrade means that we leave to the installer program to decide, if it is a new installation or an update/upgrade. The name, the version and the date of the extension. Be extra careful with the module name. Any errors will stop the installation. We use mod_yourmodule as name and will come back to the reason in a later part. Information about the author with contact data. Copyright and license. If the module will be for your own private use only, you don&#039;t need all of it. It is however a good practice to include it.&lt;br /&gt;
&lt;br /&gt;
In the description you obviously explain what the module is supposed to do.&lt;br /&gt;
&lt;br /&gt;
In the files part you define what files and folders are included in your module. folder has the effect that all included files will be copied from your packed installation file to that directory (=folder). You don&#039;t have to include mod_yourmodule.xml here as it always will be copied.&lt;br /&gt;
&lt;br /&gt;
Comment: We did not include any index.html files. These were used to prevent users to attempt to list the content by pointing their browser to these folders. Joomla! has dropped this requirement. Acces is blocked by your .htaccess / web.config file if properly set up. The default of those files include the needed settings.&lt;br /&gt;
&lt;br /&gt;
We&#039;ll come back to &amp;amp;lt;config&amp;amp;gt; when we extend the functionality. It stays empty for now.&lt;br /&gt;
&lt;br /&gt;
Edit this file and replace the data with your own name/modulename.&lt;br /&gt;
&lt;br /&gt;
Save and close mod_yourmodule.xml&lt;br /&gt;
&lt;br /&gt;
=== The start up file ===&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll have a look at the entry point file mod_yourmodule.php.&lt;br /&gt;
&lt;br /&gt;
===== mod_yourmodule.php =====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
require JModuleHelper::getLayoutPath(&#039;mod_yourmodule&#039;, $params-&amp;gt;get(&#039;layout&#039;, &#039;default&#039;));&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Not more than this is needed for the most basic module we develop in this first tutorial part.&lt;br /&gt;
&lt;br /&gt;
You tell the system that this is php code and write a comment. You can find example comments in any Joomla! core php file or any 3.d party extension. You can add more information if you like but do not overdo. If you use functionality from another developers in the code it&#039;s a nice practice to mention that. Something like : this is a fork of mod_yourmodule by Joomla Doe. &lt;br /&gt;
&lt;br /&gt;
The line defined(... has to be included! It prevents users from running this php code from outside of Joomla!.&lt;br /&gt;
&lt;br /&gt;
The last line calls the default.php file that includes the output commands ( name without php ending ). You can see that the confusing word layout is used. Here it means a file in the tmpl folder.&lt;br /&gt;
&lt;br /&gt;
{{Tip|Do not add a php closing tag &#039; ?&amp;gt;&#039; at the end of a php file. Add an empty line at the end of files.}}&lt;br /&gt;
&lt;br /&gt;
Edit the module name and save. Do not close it if your editor allows to hold two or more files open.&lt;br /&gt;
&lt;br /&gt;
If you want to know more about Joomla! coding standards: [http://joomla.github.io/coding-standards/ joomla coding-standards] Contibutions to Joomla! core development must follow those standards.&lt;br /&gt;
&lt;br /&gt;
More for advanced developers: [[Joomla_CodeSniffer|Joomla CodeSniffer]] and [https://github.com/joomla/coding-standards/tree/master/IDE joomla/ coding-standards - IDE]&lt;br /&gt;
&lt;br /&gt;
=== The output/template/layout file ===&lt;br /&gt;
&lt;br /&gt;
The last file to edit before we enable the module for the frontend pages is the default.php&lt;br /&gt;
&lt;br /&gt;
===== default.php =====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;From your first module&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;This is the content&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the comments part - that you changed - from the former php file and paste it here, replacing the comment. After the obligatory defined(... line we close the php part with ?&amp;gt;. The rest is at your disposal. Use the knowledge you have of html code to show text on the frontpage. Alternatively you can write a very short article in the Joomla! backend, toggle the editor and copy the source code to the php file. If you do, save the article and note the article. We&#039;ll use an article as source in a later step.&lt;br /&gt;
&lt;br /&gt;
After saving the file we are ready to enable your custom module on the frontend.&lt;br /&gt;
&lt;br /&gt;
=== Install and enable the module ===&lt;br /&gt;
&lt;br /&gt;
{{Tip|Before you proceed it might be a good idea to backup your test site. Well, only in case of ...}}&lt;br /&gt;
The most simple way to backup your local server is to copy the whole web directory. It includes both your local site and the database. See path examples above. &lt;br /&gt;
&lt;br /&gt;
We do not need to create a compressed installation file (.zip) to install an extension. We&#039;ll use the Discover method.&lt;br /&gt;
&lt;br /&gt;
Go to {{rarr|Extensions,Extension Manager,Click on Discover}}, in the Extension Manager:Discover menu you click on the Discover button&lt;br /&gt;
&lt;br /&gt;
Mark your module in the list and click on the Install button. If everything went well, you&#039;ll get a message that tells you that the module was installed.&lt;br /&gt;
&lt;br /&gt;
At last you enable the module in the Module Manager. Click on New and find it in the the list. As difference to &amp;quot;normal&amp;quot; module installation the Discover method probably did not add an entry to the module instances list. The name is mod_yourmodule so you&#039;ll find it lower case sorted to the end of the list . We&#039;ll fix that in the next tutorial part.&lt;br /&gt;
&lt;br /&gt;
Info for new Joomla! users: You can create multiple instances/copies of a module. Each with different option settings. That is what you do when you click on the New button.&lt;br /&gt;
&lt;br /&gt;
Add a title, choose a module position and publish. Go to the frontend and see your first module creation. You can now modify the default.php file to get something fancy before you go on to the next step in the tutorial.&lt;br /&gt;
&lt;br /&gt;
{{Tip|To remember for ever. Do not forget to click the Menu Assignment tab in the Module Manager. Promised: You will! }}&lt;br /&gt;
&lt;br /&gt;
More about [[Module|Joomla! Modules]]&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Basic&amp;diff=125266</id>
		<title>User:Over/Step by step to a Joomla Module - Basic</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Basic&amp;diff=125266"/>
		<updated>2014-09-09T09:33:29Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Prepare files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you&lt;br /&gt;
&lt;br /&gt;
* have some interest in understanding the Joomla! Cms a little under the hood.&lt;br /&gt;
* are new to Joomla and want to be able to modify your site more than per option settings.&lt;br /&gt;
* have knowledge in web development but not with the Joomla! Cms&lt;br /&gt;
&lt;br /&gt;
this is something for you.&lt;br /&gt;
&lt;br /&gt;
{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
The first step will show you how to get your own custom module running in just a few minutes. Well, you have of course to subtract the time it takes to read and follow this text from the total time.&lt;br /&gt;
&lt;br /&gt;
If you run into problems, you can´t solve yourself, ask on the various Joomla developer communication channels.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
Before we start, some words about the requirements. You need access to a system with version 3.x of Joomla! installed. This with a web server - PHP, MySQL and Apache ( or a Microsoft IIS server ). A very good idea is to install a server on your local system. It will allow you to test any future changes, before you implement it on your live server. You can find documentation and hints how to do that by searching the www for Joomla and WAMP, LAMP, XAMPP, MAMP ...&lt;br /&gt;
&lt;br /&gt;
Example, without preference, from the Joomla! Community Magazine [http://magazine.joomla.org/issues/issue-mar-2013/item/1110-free-e-book-%E2%80%93-introducing-joomla-30-made-easy Installing Joomla 3.0 on local host using XAMPP] There are many users that find MAMP for Mac or WAMP for Windows easier to install and run.&lt;br /&gt;
&lt;br /&gt;
For the coding you need an editor. If you plan to develop in a larger scale you probably want to use an IDE, integrated development enviroment, or already have one. You can find information on alternatives elsewhere. If you only want to follow this tutorial and later make some minor changes (overrides) you can use a simpler editor. Search one for your local system. For Windows is Notepad++ an example. IMPORTANT! The Editor must be able to save the files with Unix type end of line (EOL) and character set UTF-8 w/o BOM (without byte order mark). You have to set this in the settings of the editor you use. This is a Joomla! requirement and may leave you with some surprises, if you don&#039;t follow it.&lt;br /&gt;
&lt;br /&gt;
[[Setting_up_your_workstation_for_Joomla_development|More technical documentation]]&lt;br /&gt;
&lt;br /&gt;
=== Prepare files ===&lt;br /&gt;
&lt;br /&gt;
Be sure that you have set error reporting to Development on your development system. {{rarr|System,Global,Server Settings,Error Reporting}} -&amp;gt; Development. Never on a live system.&lt;br /&gt;
&lt;br /&gt;
OK! If you now have got it all together, let&#039;s start. There are some zipped files available. We&#039;ll use them as skeletons for the code we create. Download [http://github.com/schnuti/module-tutorial/zipball/master/ !!! replace with Joomla download !!!] to a new folder you can easily find. e.g. &#039;somewhere&#039;/j3_module_tutorial. Unzip it. As we are in the mood of creating folders add another subfolder e.g. &#039;somewhere&#039;/j3_module_tutorial/new_module. We will use that in a next tutorial to create the installation file for your module.&lt;br /&gt;
&lt;br /&gt;
Something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/&#039;somewhere&#039;&lt;br /&gt;
  /j3_module_tutorial        *new directory*&lt;br /&gt;
    /&#039;unpacked zip&#039;      &lt;br /&gt;
      ...                    *the files*&lt;br /&gt;
  /new_module                *new directory*&lt;br /&gt;
    ...                      *your own module files*&lt;br /&gt;
  downloaded.zip          &lt;br /&gt;
  mod_yourmodule_x_y_z.zip   *created during tutorial*&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should choose another name for your custom module. Development in a FOSS enviroment, free open source software, is not much about entering code. You use available code, copy/paste and make some modifications. At the end of this tutorial you&#039;ll have your own module, that you can use as &amp;quot;framework&amp;quot; for your next &amp;quot;module idea&amp;quot;. You only have to replace the name you gave the module with a new name.  We&#039;ll use &amp;quot;Yourmodule&amp;quot; throughout the tutorial. Always substitute this with your chosen name! Most of the times you have to use lower case as now with the directories and filenames. You do not have to understand every detail of the code lines. Just copy/paste and change the module name. You can for sure find deeper information about your special interests in web development. &lt;br /&gt;
&lt;br /&gt;
Look up the Joomla! root directory on your test system. It depends on your server and Joomla! installation. For Wamp it might be c:\wamp\www\joomla. For XAMPP c:\xampp\htdocs\joomla. Here you&#039;ll find a modules directory where you create a subdirectory mod_yourmodule. Don&#039;t forget to use your own name! We also need a mod_yourmodule/tmpl directory.&lt;br /&gt;
&lt;br /&gt;
In this step we&#039;ll only use 3 files. mod_yourmodule.xml - the so called manifest file that controls the installation and in the module case holds any configuration options, mod_yourmodule.php is the start up file / entry point. default.php holds the code for output. The latter can be named otherwise and is also called template or layout. Somewhat confusing as template and layout is used also in other contexts.&lt;br /&gt;
&lt;br /&gt;
Now you copy mod_yourmodule.xml and mod_yourmodule.php to your path/to/joomla/modules/mod_yourmodule directory. Rename! You copy default.php to path/to/joomla/modules/mod_yourmodule/tmpl.&lt;br /&gt;
&lt;br /&gt;
After you created the 2 new directories and copied the 3 new files your Joomla path should look like below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/media&lt;br /&gt;
/modules&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /tmpl                  *new directory*&lt;br /&gt;
      default.php          *new file*&lt;br /&gt;
    mod_yourmodule.php     *new file*&lt;br /&gt;
    mod_yourmodule.xml     *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/plugins&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The modules xml file ===&lt;br /&gt;
&lt;br /&gt;
Open mod_yourmodule.xml with your editor. We&#039;ll have a look at what we have there and make some modifications.&lt;br /&gt;
&lt;br /&gt;
More information about [[Manifest_files|Manifest files]]. We will come back to this file more than once to add more tags and definitions.&lt;br /&gt;
&lt;br /&gt;
===== mod_yourmodule.xml =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;module&amp;quot; version=&amp;quot;3.3.0&amp;quot; client=&amp;quot;site&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;name&amp;gt;mod_yourmodule&amp;lt;/name&amp;gt;&lt;br /&gt;
    &amp;lt;version&amp;gt;1.0.0&amp;lt;/version&amp;gt;&lt;br /&gt;
	&amp;lt;creationDate&amp;gt;August 2014&amp;lt;/creationDate&amp;gt;&lt;br /&gt;
    &amp;lt;author&amp;gt;Joomla Doe&amp;lt;/author&amp;gt;&lt;br /&gt;
	&amp;lt;authorUrl&amp;gt;www.yourmodule.org&amp;lt;/authorUrl&amp;gt;&lt;br /&gt;
 	&amp;lt;authorEmail&amp;gt;joomla.doe@yourmodule.org&amp;lt;/authorEmail&amp;gt;&lt;br /&gt;
	&amp;lt;copyright&amp;gt;Copyright (C) 2014 Joomla Doe&amp;lt;/copyright&amp;gt;&lt;br /&gt;
	&amp;lt;license&amp;gt;GNU General Public License version 2 or later; see LICENSE.txt&amp;lt;/license&amp;gt;&lt;br /&gt;
    &amp;lt;description&amp;gt;Your own first custom module.&amp;lt;/description&amp;gt;&lt;br /&gt;
    &amp;lt;files&amp;gt;&lt;br /&gt;
        &amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
        &amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
        &amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
    &amp;lt;/files&amp;gt;&lt;br /&gt;
    &amp;lt;config&amp;gt;&lt;br /&gt;
    &amp;lt;/config&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The content of the xml file is almost self explaining. We define the extension as a module for Joomla! versions 3.3.0 and above. 3.3.3 is the latest version at the time of creating the tutorial Upgrade means that we leave to the installer program to decide, if it is a new installation or an update/upgrade. The name, the version and the date of the extension. Be extra careful with the module name. Any errors will stop the installation. We use mod_yourmodule as name and will come back to the reason in a later part. Information about the author with contact data. Copyright and license. If the module will be for your own private use only, you don&#039;t need all of it. It is however a good practice to include it.&lt;br /&gt;
&lt;br /&gt;
In the description you obviously explain what the module is supposed to do.&lt;br /&gt;
&lt;br /&gt;
In the files part you define what files and folders are included in your module. folder has the effect that all included files will be copied from your packed installation file to that directory (=folder). You don&#039;t have to include mod_yourmodule.xml here as it always will be copied.&lt;br /&gt;
&lt;br /&gt;
Comment: We did not include any index.html files. These were used to prevent users to attempt to list the content by pointing their browser to these folders. Joomla! has dropped this requirement. Acces is blocked by your .htaccess / web.config file if properly set up. The default of those files include the needed settings.&lt;br /&gt;
&lt;br /&gt;
We&#039;ll come back to &amp;amp;lt;config&amp;amp;gt; when we extend the functionality. It stays empty for now.&lt;br /&gt;
&lt;br /&gt;
Edit this file and replace the data with your own name/modulename.&lt;br /&gt;
&lt;br /&gt;
Save and close mod_yourmodule.xml&lt;br /&gt;
&lt;br /&gt;
=== The start up file ===&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll have a look at the entry point file mod_yourmodule.php.&lt;br /&gt;
&lt;br /&gt;
===== mod_yourmodule.php =====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
require JModuleHelper::getLayoutPath(&#039;mod_yourmodule&#039;, $params-&amp;gt;get(&#039;layout&#039;, &#039;default&#039;));&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Not more than this is needed for the most basic module we develop in this first tutorial part.&lt;br /&gt;
&lt;br /&gt;
You tell the system that this is php code and write a comment. You can find example comments in any Joomla! core php file or any 3.d party extension. You can add more information if you like but do not overdo. If you use functionality from another developers in the code it&#039;s a nice practice to mention that. Something like : this is a fork of mod_yourmodule by Joomla Doe. &lt;br /&gt;
&lt;br /&gt;
The line defined(... has to be included! It prevents users from running this php code from outside of Joomla!.&lt;br /&gt;
&lt;br /&gt;
The last line calls the default.php file that includes the output commands ( name without php ending ). You can see that the confusing word layout is used. Here it means a file in the tmpl folder.&lt;br /&gt;
&lt;br /&gt;
{{Tip|Do not add a php closing tag &#039; ?&amp;gt;&#039; at the end of a php file. Add an empty line at the end of files.}}&lt;br /&gt;
&lt;br /&gt;
Edit the module name and save. Do not close it if your editor allows to hold two or more files open.&lt;br /&gt;
&lt;br /&gt;
If you want to know more about Joomla! coding standards: [http://joomla.github.io/coding-standards/ joomla coding-standards] Contibutions to Joomla! core development must follow those standards.&lt;br /&gt;
&lt;br /&gt;
More for advanced developers: [[Joomla_CodeSniffer|Joomla CodeSniffer]] and [https://github.com/joomla/coding-standards/tree/master/IDE joomla/ coding-standards - IDE]&lt;br /&gt;
&lt;br /&gt;
=== The output/template/layout file ===&lt;br /&gt;
&lt;br /&gt;
The last file to edit before we enable the module for the frontend pages is the default.php&lt;br /&gt;
&lt;br /&gt;
===== default.php =====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;From your first module&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;This is the content&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the comments part - that you changed - from the former php file and paste it here, replacing the comment. After the obligatory defined(... line we close the php part with ?&amp;gt;. The rest is at your disposal. Use the knowledge you have of html code to show text on the frontpage. Alternatively you can write a very short article in the Joomla! backend, toggle the editor and copy the source code to the php file. If you do, save the article and note the article. We&#039;ll use an article as source in a later step.&lt;br /&gt;
&lt;br /&gt;
After saving the file we are ready to enable your custom module on the frontend.&lt;br /&gt;
&lt;br /&gt;
=== Install and enable the module ===&lt;br /&gt;
&lt;br /&gt;
{{Tip|Before you proceed it might be a good idea to backup your test site. Well, only in case of ...}}&lt;br /&gt;
The most simple way to backup your local server is to copy the whole web directory. It includes both your local site and the database. See path examples above. &lt;br /&gt;
&lt;br /&gt;
We do not need to create a compressed installation file (.zip) to install an extension. We&#039;ll use the Discover method.&lt;br /&gt;
&lt;br /&gt;
Go to {{rarr|Extensions,Extension Manager,Click on Discover}}, in the Extension Manager:Discover menu you click on the Discover button&lt;br /&gt;
&lt;br /&gt;
Mark your module in the list and click on the Install button. If everything went well, you&#039;ll get a message that tells you that the module was installed.&lt;br /&gt;
&lt;br /&gt;
At last you enable the module in the Module Manager. Click on New and find it in the the list. As difference to &amp;quot;normal&amp;quot; module installation the Discover method probably did not add an entry to the module instances list. The name is mod_yourmodule so you&#039;ll find it lower case sorted to the end of the list . We&#039;ll fix that in the next tutorial part.&lt;br /&gt;
&lt;br /&gt;
Info for new Joomla! users: You can create multiple instances/copies of a module. Each with different option settings. That is what you do when you click on the New button.&lt;br /&gt;
&lt;br /&gt;
Add a title, choose a module position and publish. Go to the frontend and see your first module creation. You can now modify the default.php file to get something fancy before you go on to the next step in the tutorial.&lt;br /&gt;
&lt;br /&gt;
{{Tip|To remember for ever. Do not forget to click the Menu Assignment tab in the Module Manager. Promised: You will! }}&lt;br /&gt;
&lt;br /&gt;
More about [[Module|Joomla! Modules]]&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Overrides&amp;diff=125265</id>
		<title>User:Over/Step by step to a Joomla Module - Overrides</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Overrides&amp;diff=125265"/>
		<updated>2014-09-09T09:17:41Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Overriding */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
In this step we&#039;ll use your custom module to show you how you can use the powerful Joomla! methods to override ( = change ) the output. The same possibilities are valid for all modules and components that follows the Joomla! best practice.&lt;br /&gt;
&lt;br /&gt;
=== Your site template directory ===&lt;br /&gt;
&lt;br /&gt;
As you probably know, your template is found under the templates/ folder in your Joomla! directory. The folders important for our overrides are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/templates&lt;br /&gt;
  ...&lt;br /&gt;
  /mytemplate&lt;br /&gt;
    /css&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule.css&lt;br /&gt;
      ...&lt;br /&gt;
    /html&lt;br /&gt;
      ...&lt;br /&gt;
      /com_mycomponent&lt;br /&gt;
        /view1&lt;br /&gt;
          default.php&lt;br /&gt;
        /view2&lt;br /&gt;
          default.php&lt;br /&gt;
      ...&lt;br /&gt;
      /layouts&lt;br /&gt;
        /joomla&lt;br /&gt;
          /content&lt;br /&gt;
            /info_block&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        default.php          &lt;br /&gt;
        alternative.php&lt;br /&gt;
      ...&lt;br /&gt;
    /images&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule-logo.png&lt;br /&gt;
      ...&lt;br /&gt;
    /js&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule.js&lt;br /&gt;
    ...&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The illustration above shows the paths and some of the files in your templates folder.&lt;br /&gt;
If we add files in those directories, they will be used instead of the extensions original files.&lt;br /&gt;
You can use the Template Manager to easily create overrides in the html path.  [[J3.x:How_to_use_the_Template_Manager|J3.x:How to use the Template Manager]]&lt;br /&gt;
&lt;br /&gt;
Be aware of that if you use a template including overrides, you have to find a way to protect your custom overrides when the template is updated. e.g. if you use the Beez3 template, you can create a copy of this template. See the Template Manager.&lt;br /&gt;
&lt;br /&gt;
We can also override css, images and javascripts that are loaded with the JHtml functions and &#039;relative&#039; to the media/ folder. We&#039;ll show this with the custom module you have created in this tutorial.&lt;br /&gt;
&lt;br /&gt;
=== Overriding ===&lt;br /&gt;
&lt;br /&gt;
Use the Template Manager or your file manager to copy the default.php from the /tmpl folder in your module to yourtemplate/html/mod_yourmodule/ as shown above. Open the copy with your editor and make some visual changes. Maybe you want to replace the Bootstrap classes if your template is not loading the Bootstrap Css. If you now refresh the browser page you&#039;ll see the changes.&lt;br /&gt;
&lt;br /&gt;
You can create a second override for your module with another name. e.g. alternative.php and change some visible content. Now you click New in the Module Manager and choose your module. Edit the new copy of the module and choose the second override in the Advanced tab / Alternative Layout. Enable and have a look what happend. &lt;br /&gt;
&lt;br /&gt;
Note: You can add alternative layouts for your own extension by adding e.g. an alternative1.php and an alternative2.php to the /tmpl folder. Do not use a lot of parameters and alternatives. The experience shows, that it is harder for users to get the right set up and the maintenance is more complex.&lt;br /&gt;
&lt;br /&gt;
You can do the same with components. As shown above, you have to add one folder per component view, where you add the output file. The name is not always default.php. It´s also possible to create menu xml files for components alternative layouts. &lt;br /&gt;
&lt;br /&gt;
Copy the yourmodule.css file from media/mod_yourmodule/css to yourtemplate/css/mod_yourmodule/. Open this file and change css classes e.g. text to another color. Reload the page in the browser. Be aware of the browser cache. It can be, that you have to clear it to get the changed css loaded.&lt;br /&gt;
&lt;br /&gt;
Copy an image to yourtemplate/images/mod_yourmodule/ and rename it to the same name as used in the default.php. Reload the page and you&#039;ll see your image.&lt;br /&gt;
&lt;br /&gt;
The same possibility is valid for javascript. If they are loaded &#039;relative&#039; to the media/ path you can copy them to yourtemplate/js/mod_yourmodule/ and change them.&lt;br /&gt;
&lt;br /&gt;
As you remember we added two options to the module settings, load_css and load_js. A administrator/user may want to load css and/or javascript in other ways. If you use those parameters, the administrator can turn off the loading of your modules css and/or javacript without overriding the default.php. This is more important for components as css and javascript normaly not is loaded in overridable code.&lt;br /&gt;
&lt;br /&gt;
=== Examples - optional exclusion of css and javascript===&lt;br /&gt;
&lt;br /&gt;
==== default.php Css parameter ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
if ($params-&amp;gt;get(&#039;load_css&#039;, 1)) &lt;br /&gt;
{&lt;br /&gt;
   JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript parameter ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if ($params-&amp;gt;get(&#039;load_js&#039;, 1)) &lt;br /&gt;
{&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
$document = JFactory::getDocument();&lt;br /&gt;
$document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The html/layouts path ===&lt;br /&gt;
&lt;br /&gt;
A new possibility to Joomla! output is the reuse of parts of a view ( JLayout ).  An example is the use of the same &#039;layout&#039; in many of the different article views.  JLayout files use the layout paths. In the Joomla! root you can find a /layouts folder that include the core JLayout files. Have a look at the available ones. Third party components usually use an own folder in their backend path.&lt;br /&gt;
&lt;br /&gt;
To override those reused &#039;layouts&#039; you copy them to the corresponding path in your templates directory and make the changes. They will be automaticly loaded instead of the original one.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not likely that you can reuse a JLayout file in a module, but it is possible.&lt;br /&gt;
&lt;br /&gt;
=== Language string overrides ===&lt;br /&gt;
&lt;br /&gt;
We will not describe this type of overrides here. We only want to remind you of the possibility to change language strings in extensions that are not your own or add languga constants for your overrides. Do not change the original files.&lt;br /&gt;
&lt;br /&gt;
Go to {{rarr|Extensions,Language Manager,Overrides}} to create overrides that change texts.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125262</id>
		<title>User:Over/Step by step to a Joomla Module - Data retrieval and styling</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125262"/>
		<updated>2014-09-08T15:28:09Z</updated>

		<summary type="html">&lt;p&gt;Over: /* helper.php - The sql commands */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to retrieve data from a database table in two ways, direct access to a table and using a components methods. You have to have installed the module you created in former parts of the tutorial, before you start to follow this part.&lt;br /&gt;
&lt;br /&gt;
=== Data retrieval ===&lt;br /&gt;
&lt;br /&gt;
As in the previous parts you copy a skeleton file to your module folder in your Joomla path of the server. This time you copy the helper.php file to the &amp;quot;root&amp;quot; of the module.&lt;br /&gt;
&lt;br /&gt;
==== helper.php ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
abstract class ModYourmoduleHelper&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
		//we will add some code here&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The top of the file looks like any other of our php files. Copy your own comment lines from one of the php files you have edited in the former parts of the tutorial. Then we have a class definition with a name following a convention you as well should follow. Mod + The module name + Helper. A comment block follows describing what the following function does. We will add our code within the function ( in developer language called method ). You have to read the coding standards or have a look in any Joomla! core php file to learn more about coding and commenting conventions.&lt;br /&gt;
&lt;br /&gt;
We will use an article to have a litle more dynamic data example. If you didn&#039;t create an article earlier in this tutorial series do that now. Keep it short as it&#039;s only an example. In the Module Manager you open your module and under the option tab you choose your article example. You see the title but actually the article id number is stored as parameter value.&lt;br /&gt;
&lt;br /&gt;
In the first example we&#039;ll get the article text by sending sql statements to the Joomla! database API.&lt;br /&gt;
&lt;br /&gt;
==== helper.php - The sql commands ====&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		//get the users authorisations&lt;br /&gt;
		$user       = JFactory::getUser();&lt;br /&gt;
		$groups     = implode(&#039;,&#039;, $user-&amp;gt;getAuthorisedViewLevels());&lt;br /&gt;
&lt;br /&gt;
		$db = JFactory::getDbo();&lt;br /&gt;
   		//get a db query object&lt;br /&gt;
		$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
		//select article id, title and introtext&lt;br /&gt;
		$query-&amp;gt;select(&lt;br /&gt;
			array(&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.id&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.title&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.introtext&#039;),&lt;br /&gt;
				)&lt;br /&gt;
		);&lt;br /&gt;
   		//from the article table&lt;br /&gt;
		$query-&amp;gt;from($db-&amp;gt;quoteName(&#039;#__content&#039;, &#039;a&#039;));&lt;br /&gt;
		//id from parameter, we cast to integer&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;id&#039;) . &#039; = &#039;. (int) $id);&lt;br /&gt;
		// Only return if published&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;a.state&#039;) . &#039; = 1 &#039;);&lt;br /&gt;
		//and user is authorised to read&lt;br /&gt;
                $query-&amp;gt;where($this-&amp;gt;db-&amp;gt;quoteName(&#039;a.access&#039;) . &#039; IN (&#039; . $groups . &#039;)&#039;);&lt;br /&gt;
&lt;br /&gt;
		//uncomment this line to see the query string&lt;br /&gt;
		//echo $query;&lt;br /&gt;
&lt;br /&gt;
		$db-&amp;gt;setQuery($query);&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
	   		//get the article&lt;br /&gt;
			$result = $db-&amp;gt;loadObject();&lt;br /&gt;
		}&lt;br /&gt;
   		//check error&lt;br /&gt;
		catch (RuntimeException $e)&lt;br /&gt;
		{&lt;br /&gt;
			//this is a module so we skip it if there are errors&lt;br /&gt;
			// in other cases we would show a message&lt;br /&gt;
			//$app = JFactory::getApplication();&lt;br /&gt;
			//$app-&amp;gt;enqueueMessage($e-&amp;gt;getMessage(), &#039;error&#039;);&lt;br /&gt;
&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $result;&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the brief comments in the text about what we are doing here. &lt;br /&gt;
&lt;br /&gt;
Important security issue: use $db-&amp;gt;quote($field_value) to avoid so called &amp;quot;sql-injections&amp;quot; for none integer or float variables. Use (int) and (float) for those. Be very careful when you build sql queries. &lt;br /&gt;
&lt;br /&gt;
db-&amp;gt;quoteName(&#039;field_name&#039;) escapes the name database dependent. We can&#039;t describe more details to Joomla! sql queries within this tutorial. More in [http://docs.joomla.org/Accessing_the_database_using_JDatabase Accessing the database using JDatabase]&lt;br /&gt;
&lt;br /&gt;
As this is a module we don&#039;t show errormessages to the user. If there are errors the page will still be ok.&lt;br /&gt;
&lt;br /&gt;
Copy the code to your helper.php replacing the method ( = function ) getData.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The helper file is loaded and run from mod_yourmodule.php. Open it and add the following between defined(... and require.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.php - Load helper class ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    // Include the helper file that provide the data&lt;br /&gt;
   require __DIR__ . &#039;/helper.php&#039;;&lt;br /&gt;
&lt;br /&gt;
   //the class suffix from parameter&lt;br /&gt;
   $moduleclass_sfx = htmlspecialchars($params-&amp;gt;get(&#039;moduleclass_sfx&#039;));&lt;br /&gt;
 &lt;br /&gt;
  if ( !$article = ModYourmoduleHelper::getData($params))&lt;br /&gt;
   {&lt;br /&gt;
      //if error or article not found skip this module&lt;br /&gt;
      return false;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //uncomment this line to see the available fields&lt;br /&gt;
   //var_dump($article);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the same time we get the class suffix from the parameter. Explained below.&lt;br /&gt;
Now that you have the article data, we will change the output file to show it. Remember? /tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
==== default.php - Show article ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After defined(... and the php closing tab we change the html. We use embedded php code to echo the title and the introtext. We add a module specific class $moduleclass sfx to the div tag. $moduleclass sfx is the class suffix the user can add in the Module Manager -&amp;amp;gt; tab Advanced. This can be used for Css styling if multiple instances of the same module are enabled. e.g. you can test to reuse your module by choosing another article. We will style them in the next step.&lt;br /&gt;
&lt;br /&gt;
=== Css styling ===&lt;br /&gt;
Best practice on a website is to &#039;&#039;&#039;try&#039;&#039;&#039; to keep all css styling in one file. As you don&#039;t know if the users template shows your module as designed, you have to include a css file. Not really for what we have above, but in a tutorial we do as if. You should use the parameters we created in a former part, to let the user of the module exclude your css. Described in the Overrides part of the tutorial.&lt;br /&gt;
&lt;br /&gt;
We will not only prepare for loading css but also for images and javascript. Best practice is to store those files in subfolders of the Joomla media folder. Please don&#039;t ask why this folder was named media.&lt;br /&gt;
&lt;br /&gt;
Create folder path/to/your/joomla/media/mod_yourmodule. In the folder where you unpacked the tutorial zip file you&#039;ll find a media folder. Open this and copy all three subfolders to the new folder in your web folder. It should result in something like this &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/logs&lt;br /&gt;
/media&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /css                   *new directory*&lt;br /&gt;
      yourmodule.css       *new file*&lt;br /&gt;
    /images                *new directory*&lt;br /&gt;
      doc.png              *new file*&lt;br /&gt;
      yourmodule-logo.png  *new file*&lt;br /&gt;
    /js                    *new directory*&lt;br /&gt;
      yourmodule.js        *new file*&lt;br /&gt;
      yourmodule_ajax.js   *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/modules&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Did you use your module name? You don´t have to, but it´s a good practice to use distinct names.&lt;br /&gt;
&lt;br /&gt;
=== Add Css file  ===&lt;br /&gt;
&lt;br /&gt;
We include the module specific css file to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
==== default.php - Include Css file and image ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div class=&amp;quot;row text-center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;?php echo JHtml::image(&#039;mod_yourmodule/yourmodule-logo.png&#039;, &#039;Yourmodule logo&#039;, &#039;&#039;, true, false );?&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this code added yourmodule.css will be loaded from the path media/mod_yourmodule/css/&lt;br /&gt;
Be aware of the missing /css/ ! This is added by Joomla. The image will be loaded from the path media/mod_yourmodule/images/.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s test that the css is working by adding a few lines to the yourmodule.css file. Open it with the editor and add e.g. those lines that change text color. Do we have to mention the module name that was used as css class?&lt;br /&gt;
&lt;br /&gt;
==== yourmodule.css ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
.yourmodule h4{&lt;br /&gt;
	color: #08c;&lt;br /&gt;
}&lt;br /&gt;
.yourmodule p {&lt;br /&gt;
	color: #005580;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On your frontend page the colors should have changed and an image added. Have a look! Be aware that your browser may have cached the css.&lt;br /&gt;
&lt;br /&gt;
=== Update the xml and the zip file  ===&lt;br /&gt;
&lt;br /&gt;
Now we have to add the new files to the xml file and create an updated installation zip file.&lt;br /&gt;
&lt;br /&gt;
Add the helper.php and the special media tag to the xml file.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add helper.php ====&lt;br /&gt;
&lt;br /&gt;
Add helper.php to the files tag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;files&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;helper.php&amp;lt;/filename&amp;gt; &lt;br /&gt;
		&amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add media folder ====&lt;br /&gt;
&lt;br /&gt;
Add the media tag between files and languages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
	&amp;lt;media destination=&amp;quot;mod_yourmodule&amp;quot; folder=&amp;quot;media&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;css&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;images&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;js&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/media&amp;gt;&lt;br /&gt;
	&amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== Create the installation file ===&lt;br /&gt;
&lt;br /&gt;
Now you copy &#039;&#039;&#039;all&#039;&#039;&#039; module files from the server to the path &#039;somewhere&#039;/j_module_tutorial/new_module as in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
Create a new folder &#039;media&#039; and copy the three folders from media/mod_yourmodule.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  .../new_module&lt;br /&gt;
      /langs&lt;br /&gt;
        en-GB.mod_yourmodule.ini&lt;br /&gt;
        en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        anyother-language.mod_yourmodule.in&lt;br /&gt;
        anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /language&lt;br /&gt;
        /en-GB&lt;br /&gt;
          en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        /anyother-language&lt;br /&gt;
          anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /media&lt;br /&gt;
        /css&lt;br /&gt;
          yourmodule.css&lt;br /&gt;
        /images&lt;br /&gt;
          doc.png&lt;br /&gt;
          yourmodule-logo.png&lt;br /&gt;
        /js&lt;br /&gt;
          yourmodule.js&lt;br /&gt;
      /tmpl&lt;br /&gt;
        default.php&lt;br /&gt;
      mod_yourmodule.php&lt;br /&gt;
      mod_yourmodule.xml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the compressed installation zip file as described in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this tutorial. Below we describe an alternative for data retrieval.&lt;br /&gt;
&lt;br /&gt;
=== Use a component for data retrieval ===&lt;br /&gt;
&lt;br /&gt;
Below is an alternative to using direct sql. You can use the methods provided by a component to retrieve the data. If you develop your own component, you can prepare methods for reuse, otherwise you can try to find a method in a components models to retrieve the data you want. Here we reuse the getItem method of the content component ( articles ). In this case you get all article data returned. If you use a lot of modules of this type on the same page, be a little aware of momory usage. If you want to test it, you only have to replace the getData method in helper.php.&lt;br /&gt;
&lt;br /&gt;
To see the data available you can uncomment the var_dump line in mod_yourmodule.php.&lt;br /&gt;
&lt;br /&gt;
==== helper.php Use of component ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model = JModelLegacy::getInstance(&#039;Article&#039;, &#039;ContentModel&#039;, array(&#039;ignore_request&#039; =&amp;gt; true));&lt;br /&gt;
&lt;br /&gt;
		$app = JFactory::getApplication(&#039;site&#039;);&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;article.id&#039;, $id);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;list.offset&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
		// Load the parameters.&lt;br /&gt;
		$params = $app-&amp;gt;getParams(&#039;com_content&#039;);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;params&#039;, $params);&lt;br /&gt;
&lt;br /&gt;
		$user = JFactory::getUser();&lt;br /&gt;
&lt;br /&gt;
		if ((!$user-&amp;gt;authorise(&#039;core.edit.state&#039;, &#039;com_content&#039;)) &amp;amp;&amp;amp; (!$user-&amp;gt;authorise(&#039;core.edit&#039;, &#039;com_content&#039;)))&lt;br /&gt;
		{&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.published&#039;, 1);&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.archived&#039;, 2);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;filter.language&#039;, JLanguageMultilang::isEnabled());&lt;br /&gt;
  		&lt;br /&gt;
 		return $model-&amp;gt;getItem($id);;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add javascript to the module ===&lt;br /&gt;
&lt;br /&gt;
If you want to use javascript for yourmodule, here is an example. It loads the javascript file in the media/mod_yourmodule/js path and adds a script to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
Read more [[J3.x:Javascript_Frameworks|J3.x:Javascript Frameworks]]&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
   $document = JFactory::getDocument();&lt;br /&gt;
   $document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this code below the line that loads the css file if you want to test it.&lt;br /&gt;
&lt;br /&gt;
* We use jQuery so we have to load it &#039;&#039;&#039;before&#039;&#039;&#039; our own modules script. Here we load the Bootstrap framework that also includes jQuery. Use JHtml::_(&#039;jquery.framework&#039;) if you only need this.&lt;br /&gt;
* We add our scriptfile &amp;quot;relative&amp;quot; to the media folder.&lt;br /&gt;
* We add the script declaration directly to the document object. It gets added to the header in the html document.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Basic&amp;diff=125261</id>
		<title>User:Over/Step by step to a Joomla Module - Basic</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Basic&amp;diff=125261"/>
		<updated>2014-09-08T15:18:30Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Prepare files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you&lt;br /&gt;
&lt;br /&gt;
* have some interest in understanding the Joomla! Cms a little under the hood.&lt;br /&gt;
* are new to Joomla and want to be able to modify your site more than per option settings.&lt;br /&gt;
* have knowledge in web development but not with the Joomla! Cms&lt;br /&gt;
&lt;br /&gt;
this is something for you.&lt;br /&gt;
&lt;br /&gt;
{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
The first step will show you how to get your own custom module running in just a few minutes. Well, you have of course to subtract the time it takes to read and follow this text from the total time.&lt;br /&gt;
&lt;br /&gt;
If you run into problems, you can´t solve yourself, ask on the various Joomla developer communication channels.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
Before we start, some words about the requirements. You need access to a system with version 3.x of Joomla! installed. This with a web server - PHP, MySQL and Apache ( or a Microsoft IIS server ). A very good idea is to install a server on your local system. It will allow you to test any future changes, before you implement it on your live server. You can find documentation and hints how to do that by searching the www for Joomla and WAMP, LAMP, XAMPP, MAMP ...&lt;br /&gt;
&lt;br /&gt;
Example, without preference, from the Joomla! Community Magazine [http://magazine.joomla.org/issues/issue-mar-2013/item/1110-free-e-book-%E2%80%93-introducing-joomla-30-made-easy Installing Joomla 3.0 on local host using XAMPP] There are many users that find MAMP for Mac or WAMP for Windows easier to install and run.&lt;br /&gt;
&lt;br /&gt;
For the coding you need an editor. If you plan to develop in a larger scale you probably want to use an IDE, integrated development enviroment, or already have one. You can find information on alternatives elsewhere. If you only want to follow this tutorial and later make some minor changes (overrides) you can use a simpler editor. Search one for your local system. For Windows is Notepad++ an example. IMPORTANT! The Editor must be able to save the files with Unix type end of line (EOL) and character set UTF-8 w/o BOM (without byte order mark). You have to set this in the settings of the editor you use. This is a Joomla! requirement and may leave you with some surprises, if you don&#039;t follow it.&lt;br /&gt;
&lt;br /&gt;
[[Setting_up_your_workstation_for_Joomla_development|More technical documentation]]&lt;br /&gt;
&lt;br /&gt;
=== Prepare files ===&lt;br /&gt;
&lt;br /&gt;
Be sure that you have set error reporting to Development on your development system. {{rarr|System,Global,Server Settings,Error Reporting}} -&amp;gt; Development. Never on a live system.&lt;br /&gt;
&lt;br /&gt;
OK! If you now have got it all together, let&#039;s start. There are some zipped files available. We&#039;ll use them as skeletons for the code we create. Download [http://github.com/schnuti/module-tutorial/zipball/master/ !!! replace with Joomla download !!!] to a new folder you can easily find. e.g. &#039;somewhere&#039;/j3_module_tutorial. Unzip it. As we are in the mood of creating folders add another subfolder e.g. &#039;somewhere&#039;/j3_module_tutorial/new_module. We will use that in a next tutorial to create the installation file for your module.&lt;br /&gt;
&lt;br /&gt;
Something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/&#039;somewhere&#039;&lt;br /&gt;
  /j3_module_tutorial        *new directory*&lt;br /&gt;
    /&#039;unpacked zip&#039;      &lt;br /&gt;
      ...                    *the files*&lt;br /&gt;
  /new_module                *new directory*&lt;br /&gt;
    ...                      *your own module files*&lt;br /&gt;
  downloaded.zip          &lt;br /&gt;
  mod_yourmodule_x_y_z.zip   *created during tutorial*&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should choose another name for your custom module. Development in a FOSS enviroment, free open source software, is not much about entering code. You use available code, copy/paste and make some modifications. At the end of this tutorial you&#039;ll have your own module, that you can use as &amp;quot;framework&amp;quot; for your next &amp;quot;module idea&amp;quot;. You only have to replace the name you gave the module with a new name.  We&#039;ll use &amp;quot;Yourmodule&amp;quot; throughout the tutorial. Always substitute this with your chosen name! Most of the times you have to use lower case as now with the directories and filenames. &lt;br /&gt;
&lt;br /&gt;
Look up the Joomla! root directory on your test system. It depends on your server and Joomla! installation. For Wamp it might be c:\wamp\www\joomla. For XAMPP c:\xampp\htdocs\joomla. Here you&#039;ll find a modules directory where you create a subdirectory mod_yourmodule. Don&#039;t forget to use your own name! We also need a mod_yourmodule/tmpl directory.&lt;br /&gt;
&lt;br /&gt;
In this step we&#039;ll only use 3 files. mod_yourmodule.xml - the so called manifest file that controls the installation and in the module case holds any configuration options, mod_yourmodule.php is the start up file / entry point. default.php holds the code for output. The latter can be named otherwise and is also called template or layout. Somewhat confusing as template and layout is used also in other contexts.&lt;br /&gt;
&lt;br /&gt;
Now you copy mod_yourmodule.xml and mod_yourmodule.php to your path/to/joomla/modules/mod_yourmodule directory. Rename! You copy default.php to path/to/joomla/modules/mod_yourmodule/tmpl.&lt;br /&gt;
&lt;br /&gt;
After you created the 2 new directories and copied the 3 new files your Joomla path should look like below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/media&lt;br /&gt;
/modules&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /tmpl                  *new directory*&lt;br /&gt;
      default.php          *new file*&lt;br /&gt;
    mod_yourmodule.php     *new file*&lt;br /&gt;
    mod_yourmodule.xml     *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/plugins&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The modules xml file ===&lt;br /&gt;
&lt;br /&gt;
Open mod_yourmodule.xml with your editor. We&#039;ll have a look at what we have there and make some modifications.&lt;br /&gt;
&lt;br /&gt;
More information about [[Manifest_files|Manifest files]]. We will come back to this file more than once to add more tags and definitions.&lt;br /&gt;
&lt;br /&gt;
===== mod_yourmodule.xml =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;module&amp;quot; version=&amp;quot;3.3.0&amp;quot; client=&amp;quot;site&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;name&amp;gt;mod_yourmodule&amp;lt;/name&amp;gt;&lt;br /&gt;
    &amp;lt;version&amp;gt;1.0.0&amp;lt;/version&amp;gt;&lt;br /&gt;
	&amp;lt;creationDate&amp;gt;August 2014&amp;lt;/creationDate&amp;gt;&lt;br /&gt;
    &amp;lt;author&amp;gt;Joomla Doe&amp;lt;/author&amp;gt;&lt;br /&gt;
	&amp;lt;authorUrl&amp;gt;www.yourmodule.org&amp;lt;/authorUrl&amp;gt;&lt;br /&gt;
 	&amp;lt;authorEmail&amp;gt;joomla.doe@yourmodule.org&amp;lt;/authorEmail&amp;gt;&lt;br /&gt;
	&amp;lt;copyright&amp;gt;Copyright (C) 2014 Joomla Doe&amp;lt;/copyright&amp;gt;&lt;br /&gt;
	&amp;lt;license&amp;gt;GNU General Public License version 2 or later; see LICENSE.txt&amp;lt;/license&amp;gt;&lt;br /&gt;
    &amp;lt;description&amp;gt;Your own first custom module.&amp;lt;/description&amp;gt;&lt;br /&gt;
    &amp;lt;files&amp;gt;&lt;br /&gt;
        &amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
        &amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
        &amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
    &amp;lt;/files&amp;gt;&lt;br /&gt;
    &amp;lt;config&amp;gt;&lt;br /&gt;
    &amp;lt;/config&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The content of the xml file is almost self explaining. We define the extension as a module for Joomla! versions 3.3.0 and above. 3.3.3 is the latest version at the time of creating the tutorial Upgrade means that we leave to the installer program to decide, if it is a new installation or an update/upgrade. The name, the version and the date of the extension. Be extra careful with the module name. Any errors will stop the installation. We use mod_yourmodule as name and will come back to the reason in a later part. Information about the author with contact data. Copyright and license. If the module will be for your own private use only, you don&#039;t need all of it. It is however a good practice to include it.&lt;br /&gt;
&lt;br /&gt;
In the description you obviously explain what the module is supposed to do.&lt;br /&gt;
&lt;br /&gt;
In the files part you define what files and folders are included in your module. folder has the effect that all included files will be copied from your packed installation file to that directory (=folder). You don&#039;t have to include mod_yourmodule.xml here as it always will be copied.&lt;br /&gt;
&lt;br /&gt;
Comment: We did not include any index.html files. These were used to prevent users to attempt to list the content by pointing their browser to these folders. Joomla! has dropped this requirement. Acces is blocked by your .htaccess / web.config file if properly set up. The default of those files include the needed settings.&lt;br /&gt;
&lt;br /&gt;
We&#039;ll come back to &amp;amp;lt;config&amp;amp;gt; when we extend the functionality. It stays empty for now.&lt;br /&gt;
&lt;br /&gt;
Edit this file and replace the data with your own name/modulename.&lt;br /&gt;
&lt;br /&gt;
Save and close mod_yourmodule.xml&lt;br /&gt;
&lt;br /&gt;
=== The start up file ===&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll have a look at the entry point file mod_yourmodule.php.&lt;br /&gt;
&lt;br /&gt;
===== mod_yourmodule.php =====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
require JModuleHelper::getLayoutPath(&#039;mod_yourmodule&#039;, $params-&amp;gt;get(&#039;layout&#039;, &#039;default&#039;));&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Not more than this is needed for the most basic module we develop in this first tutorial part.&lt;br /&gt;
&lt;br /&gt;
You tell the system that this is php code and write a comment. You can find example comments in any Joomla! core php file or any 3.d party extension. You can add more information if you like but do not overdo. If you use functionality from another developers in the code it&#039;s a nice practice to mention that. Something like : this is a fork of mod_yourmodule by Joomla Doe. &lt;br /&gt;
&lt;br /&gt;
The line defined(... has to be included! It prevents users from running this php code from outside of Joomla!.&lt;br /&gt;
&lt;br /&gt;
The last line calls the default.php file that includes the output commands ( name without php ending ). You can see that the confusing word layout is used. Here it means a file in the tmpl folder.&lt;br /&gt;
&lt;br /&gt;
{{Tip|Do not add a php closing tag &#039; ?&amp;gt;&#039; at the end of a php file. Add an empty line at the end of files.}}&lt;br /&gt;
&lt;br /&gt;
Edit the module name and save. Do not close it if your editor allows to hold two or more files open.&lt;br /&gt;
&lt;br /&gt;
If you want to know more about Joomla! coding standards: [http://joomla.github.io/coding-standards/ joomla coding-standards] Contibutions to Joomla! core development must follow those standards.&lt;br /&gt;
&lt;br /&gt;
More for advanced developers: [[Joomla_CodeSniffer|Joomla CodeSniffer]] and [https://github.com/joomla/coding-standards/tree/master/IDE joomla/ coding-standards - IDE]&lt;br /&gt;
&lt;br /&gt;
=== The output/template/layout file ===&lt;br /&gt;
&lt;br /&gt;
The last file to edit before we enable the module for the frontend pages is the default.php&lt;br /&gt;
&lt;br /&gt;
===== default.php =====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;From your first module&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;This is the content&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the comments part - that you changed - from the former php file and paste it here, replacing the comment. After the obligatory defined(... line we close the php part with ?&amp;gt;. The rest is at your disposal. Use the knowledge you have of html code to show text on the frontpage. Alternatively you can write a very short article in the Joomla! backend, toggle the editor and copy the source code to the php file. If you do, save the article and note the article. We&#039;ll use an article as source in a later step.&lt;br /&gt;
&lt;br /&gt;
After saving the file we are ready to enable your custom module on the frontend.&lt;br /&gt;
&lt;br /&gt;
=== Install and enable the module ===&lt;br /&gt;
&lt;br /&gt;
{{Tip|Before you proceed it might be a good idea to backup your test site. Well, only in case of ...}}&lt;br /&gt;
The most simple way to backup your local server is to copy the whole web directory. It includes both your local site and the database. See path examples above. &lt;br /&gt;
&lt;br /&gt;
We do not need to create a compressed installation file (.zip) to install an extension. We&#039;ll use the Discover method.&lt;br /&gt;
&lt;br /&gt;
Go to {{rarr|Extensions,Extension Manager,Click on Discover}}, in the Extension Manager:Discover menu you click on the Discover button&lt;br /&gt;
&lt;br /&gt;
Mark your module in the list and click on the Install button. If everything went well, you&#039;ll get a message that tells you that the module was installed.&lt;br /&gt;
&lt;br /&gt;
At last you enable the module in the Module Manager. Click on New and find it in the the list. As difference to &amp;quot;normal&amp;quot; module installation the Discover method probably did not add an entry to the module instances list. The name is mod_yourmodule so you&#039;ll find it lower case sorted to the end of the list . We&#039;ll fix that in the next tutorial part.&lt;br /&gt;
&lt;br /&gt;
Info for new Joomla! users: You can create multiple instances/copies of a module. Each with different option settings. That is what you do when you click on the New button.&lt;br /&gt;
&lt;br /&gt;
Add a title, choose a module position and publish. Go to the frontend and see your first module creation. You can now modify the default.php file to get something fancy before you go on to the next step in the tutorial.&lt;br /&gt;
&lt;br /&gt;
{{Tip|To remember for ever. Do not forget to click the Menu Assignment tab in the Module Manager. Promised: You will! }}&lt;br /&gt;
&lt;br /&gt;
More about [[Module|Joomla! Modules]]&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Basic&amp;diff=125260</id>
		<title>User:Over/Step by step to a Joomla Module - Basic</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Basic&amp;diff=125260"/>
		<updated>2014-09-08T15:14:42Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Prepare files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you&lt;br /&gt;
&lt;br /&gt;
* have some interest in understanding the Joomla! Cms a little under the hood.&lt;br /&gt;
* are new to Joomla and want to be able to modify your site more than per option settings.&lt;br /&gt;
* have knowledge in web development but not with the Joomla! Cms&lt;br /&gt;
&lt;br /&gt;
this is something for you.&lt;br /&gt;
&lt;br /&gt;
{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
The first step will show you how to get your own custom module running in just a few minutes. Well, you have of course to subtract the time it takes to read and follow this text from the total time.&lt;br /&gt;
&lt;br /&gt;
If you run into problems, you can´t solve yourself, ask on the various Joomla developer communication channels.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
Before we start, some words about the requirements. You need access to a system with version 3.x of Joomla! installed. This with a web server - PHP, MySQL and Apache ( or a Microsoft IIS server ). A very good idea is to install a server on your local system. It will allow you to test any future changes, before you implement it on your live server. You can find documentation and hints how to do that by searching the www for Joomla and WAMP, LAMP, XAMPP, MAMP ...&lt;br /&gt;
&lt;br /&gt;
Example, without preference, from the Joomla! Community Magazine [http://magazine.joomla.org/issues/issue-mar-2013/item/1110-free-e-book-%E2%80%93-introducing-joomla-30-made-easy Installing Joomla 3.0 on local host using XAMPP] There are many users that find MAMP for Mac or WAMP for Windows easier to install and run.&lt;br /&gt;
&lt;br /&gt;
For the coding you need an editor. If you plan to develop in a larger scale you probably want to use an IDE, integrated development enviroment, or already have one. You can find information on alternatives elsewhere. If you only want to follow this tutorial and later make some minor changes (overrides) you can use a simpler editor. Search one for your local system. For Windows is Notepad++ an example. IMPORTANT! The Editor must be able to save the files with Unix type end of line (EOL) and character set UTF-8 w/o BOM (without byte order mark). You have to set this in the settings of the editor you use. This is a Joomla! requirement and may leave you with some surprises, if you don&#039;t follow it.&lt;br /&gt;
&lt;br /&gt;
[[Setting_up_your_workstation_for_Joomla_development|More technical documentation]]&lt;br /&gt;
&lt;br /&gt;
=== Prepare files ===&lt;br /&gt;
&lt;br /&gt;
Be sure that you have set error reporting to Development on your development system. System,Global,Server Settings,Error Reporting -&amp;gt; Development. Never on a live system.&lt;br /&gt;
&lt;br /&gt;
OK! If you now have got it all together, let&#039;s start. There are some zipped files available. We&#039;ll use them as skeletons for the code we create. Download [http://github.com/schnuti/module-tutorial/zipball/master/ !!! replace with Joomla download !!!] to a new folder you can easily find. e.g. &#039;somewhere&#039;/j3_module_tutorial. Unzip it. As we are in the mood of creating folders add another subfolder e.g. &#039;somewhere&#039;/j3_module_tutorial/new_module. We will use that in a next tutorial to create the installation file for your module.&lt;br /&gt;
&lt;br /&gt;
Something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/&#039;somewhere&#039;&lt;br /&gt;
  /j3_module_tutorial        *new directory*&lt;br /&gt;
    /&#039;unpacked zip&#039;      &lt;br /&gt;
      ...                    *the files*&lt;br /&gt;
  /new_module                *new directory*&lt;br /&gt;
    ...                      *your own module files*&lt;br /&gt;
  downloaded.zip          &lt;br /&gt;
  mod_yourmodule_x_y_z.zip   *created during tutorial*&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should choose another name for your custom module. Development in a FOSS enviroment, free open source software, is not much about entering code. You use available code, copy/paste and make some modifications. At the end of this tutorial you&#039;ll have your own module, that you can use as &amp;quot;framework&amp;quot; for your next &amp;quot;module idea&amp;quot;. You only have to replace the name you gave the module with a new name.  We&#039;ll use &amp;quot;Yourmodule&amp;quot; throughout the tutorial. Always substitute this with your chosen name! Most of the times you have to use lower case as now with the directories and filenames. &lt;br /&gt;
&lt;br /&gt;
Look up the Joomla! root directory on your test system. It depends on your server and Joomla! installation. For Wamp it might be c:\wamp\www\joomla. For XAMPP c:\xampp\htdocs\joomla. Here you&#039;ll find a modules directory where you create a subdirectory mod_yourmodule. Don&#039;t forget to use your own name! We also need a mod_yourmodule/tmpl directory.&lt;br /&gt;
&lt;br /&gt;
In this step we&#039;ll only use 3 files. mod_yourmodule.xml - the so called manifest file that controls the installation and in the module case holds any configuration options, mod_yourmodule.php is the start up file / entry point. default.php holds the code for output. The latter can be named otherwise and is also called template or layout. Somewhat confusing as template and layout is used also in other contexts.&lt;br /&gt;
&lt;br /&gt;
Now you copy mod_yourmodule.xml and mod_yourmodule.php to your path/to/joomla/modules/mod_yourmodule directory. Rename! You copy default.php to path/to/joomla/modules/mod_yourmodule/tmpl.&lt;br /&gt;
&lt;br /&gt;
After you created the 2 new directories and copied the 3 new files your Joomla path should look like below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/media&lt;br /&gt;
/modules&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /tmpl                  *new directory*&lt;br /&gt;
      default.php          *new file*&lt;br /&gt;
    mod_yourmodule.php     *new file*&lt;br /&gt;
    mod_yourmodule.xml     *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/plugins&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The modules xml file ===&lt;br /&gt;
&lt;br /&gt;
Open mod_yourmodule.xml with your editor. We&#039;ll have a look at what we have there and make some modifications.&lt;br /&gt;
&lt;br /&gt;
More information about [[Manifest_files|Manifest files]]. We will come back to this file more than once to add more tags and definitions.&lt;br /&gt;
&lt;br /&gt;
===== mod_yourmodule.xml =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;module&amp;quot; version=&amp;quot;3.3.0&amp;quot; client=&amp;quot;site&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;name&amp;gt;mod_yourmodule&amp;lt;/name&amp;gt;&lt;br /&gt;
    &amp;lt;version&amp;gt;1.0.0&amp;lt;/version&amp;gt;&lt;br /&gt;
	&amp;lt;creationDate&amp;gt;August 2014&amp;lt;/creationDate&amp;gt;&lt;br /&gt;
    &amp;lt;author&amp;gt;Joomla Doe&amp;lt;/author&amp;gt;&lt;br /&gt;
	&amp;lt;authorUrl&amp;gt;www.yourmodule.org&amp;lt;/authorUrl&amp;gt;&lt;br /&gt;
 	&amp;lt;authorEmail&amp;gt;joomla.doe@yourmodule.org&amp;lt;/authorEmail&amp;gt;&lt;br /&gt;
	&amp;lt;copyright&amp;gt;Copyright (C) 2014 Joomla Doe&amp;lt;/copyright&amp;gt;&lt;br /&gt;
	&amp;lt;license&amp;gt;GNU General Public License version 2 or later; see LICENSE.txt&amp;lt;/license&amp;gt;&lt;br /&gt;
    &amp;lt;description&amp;gt;Your own first custom module.&amp;lt;/description&amp;gt;&lt;br /&gt;
    &amp;lt;files&amp;gt;&lt;br /&gt;
        &amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
        &amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
        &amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
    &amp;lt;/files&amp;gt;&lt;br /&gt;
    &amp;lt;config&amp;gt;&lt;br /&gt;
    &amp;lt;/config&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The content of the xml file is almost self explaining. We define the extension as a module for Joomla! versions 3.3.0 and above. 3.3.3 is the latest version at the time of creating the tutorial Upgrade means that we leave to the installer program to decide, if it is a new installation or an update/upgrade. The name, the version and the date of the extension. Be extra careful with the module name. Any errors will stop the installation. We use mod_yourmodule as name and will come back to the reason in a later part. Information about the author with contact data. Copyright and license. If the module will be for your own private use only, you don&#039;t need all of it. It is however a good practice to include it.&lt;br /&gt;
&lt;br /&gt;
In the description you obviously explain what the module is supposed to do.&lt;br /&gt;
&lt;br /&gt;
In the files part you define what files and folders are included in your module. folder has the effect that all included files will be copied from your packed installation file to that directory (=folder). You don&#039;t have to include mod_yourmodule.xml here as it always will be copied.&lt;br /&gt;
&lt;br /&gt;
Comment: We did not include any index.html files. These were used to prevent users to attempt to list the content by pointing their browser to these folders. Joomla! has dropped this requirement. Acces is blocked by your .htaccess / web.config file if properly set up. The default of those files include the needed settings.&lt;br /&gt;
&lt;br /&gt;
We&#039;ll come back to &amp;amp;lt;config&amp;amp;gt; when we extend the functionality. It stays empty for now.&lt;br /&gt;
&lt;br /&gt;
Edit this file and replace the data with your own name/modulename.&lt;br /&gt;
&lt;br /&gt;
Save and close mod_yourmodule.xml&lt;br /&gt;
&lt;br /&gt;
=== The start up file ===&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll have a look at the entry point file mod_yourmodule.php.&lt;br /&gt;
&lt;br /&gt;
===== mod_yourmodule.php =====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
require JModuleHelper::getLayoutPath(&#039;mod_yourmodule&#039;, $params-&amp;gt;get(&#039;layout&#039;, &#039;default&#039;));&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Not more than this is needed for the most basic module we develop in this first tutorial part.&lt;br /&gt;
&lt;br /&gt;
You tell the system that this is php code and write a comment. You can find example comments in any Joomla! core php file or any 3.d party extension. You can add more information if you like but do not overdo. If you use functionality from another developers in the code it&#039;s a nice practice to mention that. Something like : this is a fork of mod_yourmodule by Joomla Doe. &lt;br /&gt;
&lt;br /&gt;
The line defined(... has to be included! It prevents users from running this php code from outside of Joomla!.&lt;br /&gt;
&lt;br /&gt;
The last line calls the default.php file that includes the output commands ( name without php ending ). You can see that the confusing word layout is used. Here it means a file in the tmpl folder.&lt;br /&gt;
&lt;br /&gt;
{{Tip|Do not add a php closing tag &#039; ?&amp;gt;&#039; at the end of a php file. Add an empty line at the end of files.}}&lt;br /&gt;
&lt;br /&gt;
Edit the module name and save. Do not close it if your editor allows to hold two or more files open.&lt;br /&gt;
&lt;br /&gt;
If you want to know more about Joomla! coding standards: [http://joomla.github.io/coding-standards/ joomla coding-standards] Contibutions to Joomla! core development must follow those standards.&lt;br /&gt;
&lt;br /&gt;
More for advanced developers: [[Joomla_CodeSniffer|Joomla CodeSniffer]] and [https://github.com/joomla/coding-standards/tree/master/IDE joomla/ coding-standards - IDE]&lt;br /&gt;
&lt;br /&gt;
=== The output/template/layout file ===&lt;br /&gt;
&lt;br /&gt;
The last file to edit before we enable the module for the frontend pages is the default.php&lt;br /&gt;
&lt;br /&gt;
===== default.php =====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;From your first module&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;This is the content&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the comments part - that you changed - from the former php file and paste it here, replacing the comment. After the obligatory defined(... line we close the php part with ?&amp;gt;. The rest is at your disposal. Use the knowledge you have of html code to show text on the frontpage. Alternatively you can write a very short article in the Joomla! backend, toggle the editor and copy the source code to the php file. If you do, save the article and note the article. We&#039;ll use an article as source in a later step.&lt;br /&gt;
&lt;br /&gt;
After saving the file we are ready to enable your custom module on the frontend.&lt;br /&gt;
&lt;br /&gt;
=== Install and enable the module ===&lt;br /&gt;
&lt;br /&gt;
{{Tip|Before you proceed it might be a good idea to backup your test site. Well, only in case of ...}}&lt;br /&gt;
The most simple way to backup your local server is to copy the whole web directory. It includes both your local site and the database. See path examples above. &lt;br /&gt;
&lt;br /&gt;
We do not need to create a compressed installation file (.zip) to install an extension. We&#039;ll use the Discover method.&lt;br /&gt;
&lt;br /&gt;
Go to {{rarr|Extensions,Extension Manager,Click on Discover}}, in the Extension Manager:Discover menu you click on the Discover button&lt;br /&gt;
&lt;br /&gt;
Mark your module in the list and click on the Install button. If everything went well, you&#039;ll get a message that tells you that the module was installed.&lt;br /&gt;
&lt;br /&gt;
At last you enable the module in the Module Manager. Click on New and find it in the the list. As difference to &amp;quot;normal&amp;quot; module installation the Discover method probably did not add an entry to the module instances list. The name is mod_yourmodule so you&#039;ll find it lower case sorted to the end of the list . We&#039;ll fix that in the next tutorial part.&lt;br /&gt;
&lt;br /&gt;
Info for new Joomla! users: You can create multiple instances/copies of a module. Each with different option settings. That is what you do when you click on the New button.&lt;br /&gt;
&lt;br /&gt;
Add a title, choose a module position and publish. Go to the frontend and see your first module creation. You can now modify the default.php file to get something fancy before you go on to the next step in the tutorial.&lt;br /&gt;
&lt;br /&gt;
{{Tip|To remember for ever. Do not forget to click the Menu Assignment tab in the Module Manager. Promised: You will! }}&lt;br /&gt;
&lt;br /&gt;
More about [[Module|Joomla! Modules]]&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Overrides&amp;diff=125259</id>
		<title>User:Over/Step by step to a Joomla Module - Overrides</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Overrides&amp;diff=125259"/>
		<updated>2014-09-08T15:01:40Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Overriding */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
In this step we&#039;ll use your custom module to show you how you can use the powerful Joomla! methods to override ( = change ) the output. The same possibilities are valid for all modules and components that follows the Joomla! best practice.&lt;br /&gt;
&lt;br /&gt;
=== Your site template directory ===&lt;br /&gt;
&lt;br /&gt;
As you probably know, your template is found under the templates/ folder in your Joomla! directory. The folders important for our overrides are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/templates&lt;br /&gt;
  ...&lt;br /&gt;
  /mytemplate&lt;br /&gt;
    /css&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule.css&lt;br /&gt;
      ...&lt;br /&gt;
    /html&lt;br /&gt;
      ...&lt;br /&gt;
      /com_mycomponent&lt;br /&gt;
        /view1&lt;br /&gt;
          default.php&lt;br /&gt;
        /view2&lt;br /&gt;
          default.php&lt;br /&gt;
      ...&lt;br /&gt;
      /layouts&lt;br /&gt;
        /joomla&lt;br /&gt;
          /content&lt;br /&gt;
            /info_block&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        default.php          &lt;br /&gt;
        alternative.php&lt;br /&gt;
      ...&lt;br /&gt;
    /images&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule-logo.png&lt;br /&gt;
      ...&lt;br /&gt;
    /js&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule.js&lt;br /&gt;
    ...&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The illustration above shows the paths and some of the files in your templates folder.&lt;br /&gt;
If we add files in those directories, they will be used instead of the extensions original files.&lt;br /&gt;
You can use the Template Manager to easily create overrides in the html path.  [[J3.x:How_to_use_the_Template_Manager|J3.x:How to use the Template Manager]]&lt;br /&gt;
&lt;br /&gt;
Be aware of that if you use a template including overrides, you have to find a way to protect your custom overrides when the template is updated. e.g. if you use the Beez3 template, you can create a copy of this template. See the Template Manager.&lt;br /&gt;
&lt;br /&gt;
We can also override css, images and javascripts that are loaded with the JHtml functions and &#039;relative&#039; to the media/ folder. We&#039;ll show this with the custom module you have created in this tutorial.&lt;br /&gt;
&lt;br /&gt;
=== Overriding ===&lt;br /&gt;
&lt;br /&gt;
Use the Template Manager or your file manager to copy the default.php from the /tmpl folder in your module to yourtemplate/html/mod_yourmodule/ as shown above. Open the copy with your editor and make some visual changes. Maybe you want to replace the Bootstrap classes if your template is not loading the Bootstrap Css. If you now refresh the browser page you&#039;ll see the changes.&lt;br /&gt;
&lt;br /&gt;
You can create a second override for your module with another name. e.g. alternative.php and change some visible content. Now you click New in the Module Manager and choose your module. Edit the new copy of the module and choose the second override in the Advanced tab / Alternative Layout. Enable and have a look what happend. &lt;br /&gt;
&lt;br /&gt;
You can do the same with components. As shown above, you have to add one folder per component view, where you add the output file. The name is not always default.php. It´s also possible to create menu xml files for components alternative layouts. &lt;br /&gt;
&lt;br /&gt;
Copy the yourmodule.css file from media/mod_yourmodule/css to yourtemplate/css/mod_yourmodule/. Open this file and change css classes e.g. text to another color. Reload the page in the browser. Be aware of the browser cache. It can be, that you have to clear it to get the changed css loaded.&lt;br /&gt;
&lt;br /&gt;
Copy an image to yourtemplate/images/mod_yourmodule/ and rename it to the same name as used in the default.php. Reload the page and you&#039;ll see your image.&lt;br /&gt;
&lt;br /&gt;
The same possibility is valid for javascript. If they are loaded &#039;relative&#039; to the media/ path you can copy them to yourtemplate/js/mod_yourmodule/ and change them.&lt;br /&gt;
&lt;br /&gt;
As you remember we added two options to the module settings, load_css and load_js. A administrator/user may want to load css and/or javascript in other ways. If you use those parameters, the administrator can turn off the loading of your modules css and/or javacript without overriding the default.php. This is more important for components as css and javascript normaly not is loaded in overridable code.&lt;br /&gt;
&lt;br /&gt;
=== Examples - optional exclusion of css and javascript===&lt;br /&gt;
&lt;br /&gt;
==== default.php Css parameter ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
if ($params-&amp;gt;get(&#039;load_css&#039;, 1)) &lt;br /&gt;
{&lt;br /&gt;
   JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript parameter ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if ($params-&amp;gt;get(&#039;load_js&#039;, 1)) &lt;br /&gt;
{&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
$document = JFactory::getDocument();&lt;br /&gt;
$document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The html/layouts path ===&lt;br /&gt;
&lt;br /&gt;
A new possibility to Joomla! output is the reuse of parts of a view ( JLayout ).  An example is the use of the same &#039;layout&#039; in many of the different article views.  JLayout files use the layout paths. In the Joomla! root you can find a /layouts folder that include the core JLayout files. Have a look at the available ones. Third party components usually use an own folder in their backend path.&lt;br /&gt;
&lt;br /&gt;
To override those reused &#039;layouts&#039; you copy them to the corresponding path in your templates directory and make the changes. They will be automaticly loaded instead of the original one.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not likely that you can reuse a JLayout file in a module, but it is possible.&lt;br /&gt;
&lt;br /&gt;
=== Language string overrides ===&lt;br /&gt;
&lt;br /&gt;
We will not describe this type of overrides here. We only want to remind you of the possibility to change language strings in extensions that are not your own or add languga constants for your overrides. Do not change the original files.&lt;br /&gt;
&lt;br /&gt;
Go to {{rarr|Extensions,Language Manager,Overrides}} to create overrides that change texts.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Overrides&amp;diff=125258</id>
		<title>User:Over/Step by step to a Joomla Module - Overrides</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Overrides&amp;diff=125258"/>
		<updated>2014-09-08T14:56:04Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Language string overrides */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
In this step we&#039;ll use your custom module to show you how you can use the powerful Joomla! methods to override ( = change ) the output. The same possibilities are valid for all modules and components that follows the Joomla! best practice.&lt;br /&gt;
&lt;br /&gt;
=== Your site template directory ===&lt;br /&gt;
&lt;br /&gt;
As you probably know, your template is found under the templates/ folder in your Joomla! directory. The folders important for our overrides are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/templates&lt;br /&gt;
  ...&lt;br /&gt;
  /mytemplate&lt;br /&gt;
    /css&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule.css&lt;br /&gt;
      ...&lt;br /&gt;
    /html&lt;br /&gt;
      ...&lt;br /&gt;
      /com_mycomponent&lt;br /&gt;
        /view1&lt;br /&gt;
          default.php&lt;br /&gt;
        /view2&lt;br /&gt;
          default.php&lt;br /&gt;
      ...&lt;br /&gt;
      /layouts&lt;br /&gt;
        /joomla&lt;br /&gt;
          /content&lt;br /&gt;
            /info_block&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        default.php          &lt;br /&gt;
        alternative.php&lt;br /&gt;
      ...&lt;br /&gt;
    /images&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule-logo.png&lt;br /&gt;
      ...&lt;br /&gt;
    /js&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule.js&lt;br /&gt;
    ...&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The illustration above shows the paths and some of the files in your templates folder.&lt;br /&gt;
If we add files in those directories, they will be used instead of the extensions original files.&lt;br /&gt;
You can use the Template Manager to easily create overrides in the html path.  [[J3.x:How_to_use_the_Template_Manager|J3.x:How to use the Template Manager]]&lt;br /&gt;
&lt;br /&gt;
Be aware of that if you use a template including overrides, you have to find a way to protect your custom overrides when the template is updated. e.g. if you use the Beez3 template, you can create a copy of this template. See the Template Manager.&lt;br /&gt;
&lt;br /&gt;
We can also override css, images and javascripts that are loaded with the JHtml functions and &#039;relative&#039; to the media/ folder. We&#039;ll show this with the custom module you have created in this tutorial.&lt;br /&gt;
&lt;br /&gt;
=== Overriding ===&lt;br /&gt;
&lt;br /&gt;
Use the Template Manager or your file manager to copy the default.php from the /tmpl folder in your module to yourtemplate/html/mod_yourmodule/ as shown above. Open the copy with your editor and make some visual changes. Maybe you want to replace the Bootstrap classes if your template is not loading the Bootstrap Css. If you now refresh the browser page you&#039;ll see the changes.&lt;br /&gt;
&lt;br /&gt;
You can create a second override for your module with another name. e.g. alternative.php and change some visible content. Now you click New in the Module Manager and choose your module. Edit the new copy of the module and choose the second override in the Advanced tab / Alternative Layout. Enable and have a look what happend. &lt;br /&gt;
&lt;br /&gt;
You can do the same with components. As shown above, you have to add one folder per component view, where you add the output file. The name is not always default.php.  &lt;br /&gt;
&lt;br /&gt;
Copy the yourmodule.css file from media/mod_yourmodule/css to yourtemplate/css/mod_yourmodule/. Open this file and change css classes e.g. text to another color. Reload the page in the browser. Be aware of the browser cache. It can be, that you have to clear it to get the changed css loaded.&lt;br /&gt;
&lt;br /&gt;
Copy an image to yourtemplate/images/mod_yourmodule/ and rename it to the same name as used in the default.php. Reload the page and you&#039;ll see your image.&lt;br /&gt;
&lt;br /&gt;
The same possibility is valid for javascript. If they are loaded &#039;relative&#039; to the media/ path you can copy them to yourtemplate/js/mod_yourmodule/ and change them.&lt;br /&gt;
&lt;br /&gt;
As you remember we added two options to the module settings, load_css and load_js. A administrator/user may want to load css and/or javascript in other ways. If you use those parameters, the administrator can turn off the loading of your modules css and/or javacript without overriding the default.php. This is more important for components as css and javascript normaly not is loaded in overridable code.&lt;br /&gt;
&lt;br /&gt;
=== Examples - optional exclusion of css and javascript===&lt;br /&gt;
&lt;br /&gt;
==== default.php Css parameter ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
if ($params-&amp;gt;get(&#039;load_css&#039;, 1)) &lt;br /&gt;
{&lt;br /&gt;
   JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript parameter ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if ($params-&amp;gt;get(&#039;load_js&#039;, 1)) &lt;br /&gt;
{&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
$document = JFactory::getDocument();&lt;br /&gt;
$document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The html/layouts path ===&lt;br /&gt;
&lt;br /&gt;
A new possibility to Joomla! output is the reuse of parts of a view ( JLayout ).  An example is the use of the same &#039;layout&#039; in many of the different article views.  JLayout files use the layout paths. In the Joomla! root you can find a /layouts folder that include the core JLayout files. Have a look at the available ones. Third party components usually use an own folder in their backend path.&lt;br /&gt;
&lt;br /&gt;
To override those reused &#039;layouts&#039; you copy them to the corresponding path in your templates directory and make the changes. They will be automaticly loaded instead of the original one.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not likely that you can reuse a JLayout file in a module, but it is possible.&lt;br /&gt;
&lt;br /&gt;
=== Language string overrides ===&lt;br /&gt;
&lt;br /&gt;
We will not describe this type of overrides here. We only want to remind you of the possibility to change language strings in extensions that are not your own or add languga constants for your overrides. Do not change the original files.&lt;br /&gt;
&lt;br /&gt;
Go to {{rarr|Extensions,Language Manager,Overrides}} to create overrides that change texts.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Basic&amp;diff=125257</id>
		<title>User:Over/Step by step to a Joomla Module - Basic</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Basic&amp;diff=125257"/>
		<updated>2014-09-08T14:52:31Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you&lt;br /&gt;
&lt;br /&gt;
* have some interest in understanding the Joomla! Cms a little under the hood.&lt;br /&gt;
* are new to Joomla and want to be able to modify your site more than per option settings.&lt;br /&gt;
* have knowledge in web development but not with the Joomla! Cms&lt;br /&gt;
&lt;br /&gt;
this is something for you.&lt;br /&gt;
&lt;br /&gt;
{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
The first step will show you how to get your own custom module running in just a few minutes. Well, you have of course to subtract the time it takes to read and follow this text from the total time.&lt;br /&gt;
&lt;br /&gt;
If you run into problems, you can´t solve yourself, ask on the various Joomla developer communication channels.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
Before we start, some words about the requirements. You need access to a system with version 3.x of Joomla! installed. This with a web server - PHP, MySQL and Apache ( or a Microsoft IIS server ). A very good idea is to install a server on your local system. It will allow you to test any future changes, before you implement it on your live server. You can find documentation and hints how to do that by searching the www for Joomla and WAMP, LAMP, XAMPP, MAMP ...&lt;br /&gt;
&lt;br /&gt;
Example, without preference, from the Joomla! Community Magazine [http://magazine.joomla.org/issues/issue-mar-2013/item/1110-free-e-book-%E2%80%93-introducing-joomla-30-made-easy Installing Joomla 3.0 on local host using XAMPP] There are many users that find MAMP for Mac or WAMP for Windows easier to install and run.&lt;br /&gt;
&lt;br /&gt;
For the coding you need an editor. If you plan to develop in a larger scale you probably want to use an IDE, integrated development enviroment, or already have one. You can find information on alternatives elsewhere. If you only want to follow this tutorial and later make some minor changes (overrides) you can use a simpler editor. Search one for your local system. For Windows is Notepad++ an example. IMPORTANT! The Editor must be able to save the files with Unix type end of line (EOL) and character set UTF-8 w/o BOM (without byte order mark). You have to set this in the settings of the editor you use. This is a Joomla! requirement and may leave you with some surprises, if you don&#039;t follow it.&lt;br /&gt;
&lt;br /&gt;
[[Setting_up_your_workstation_for_Joomla_development|More technical documentation]]&lt;br /&gt;
&lt;br /&gt;
=== Prepare files ===&lt;br /&gt;
&lt;br /&gt;
OK! If you now have got it all together, let&#039;s start. There are some zipped files available. We&#039;ll use them as skeletons for the code we create. Download [http://github.com/schnuti/module-tutorial/zipball/master/ !!! replace with Joomla download !!!] to a new folder you can easily find. e.g. &#039;somewhere&#039;/j3_module_tutorial. Unzip it. As we are in the mood of creating folders add another subfolder e.g. &#039;somewhere&#039;/j3_module_tutorial/new_module. We will use that in a next tutorial to create the installation file for your module.&lt;br /&gt;
&lt;br /&gt;
Something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/&#039;somewhere&#039;&lt;br /&gt;
  /j3_module_tutorial        *new directory*&lt;br /&gt;
    /&#039;unpacked zip&#039;      &lt;br /&gt;
      ...                    *the files*&lt;br /&gt;
  /new_module                *new directory*&lt;br /&gt;
    ...                      *your own module files*&lt;br /&gt;
  downloaded.zip          &lt;br /&gt;
  mod_yourmodule_x_y_z.zip   *created during tutorial*&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should choose another name for your custom module. Development in a FOSS enviroment, free open source software, is not much about entering code. You use available code, copy/paste and make some modifications. At the end of this tutorial you&#039;ll have your own module, that you can use as &amp;quot;framework&amp;quot; for your next &amp;quot;module idea&amp;quot;. You only have to replace the name you gave the module with a new name.  We&#039;ll use &amp;quot;Yourmodule&amp;quot; throughout the tutorial. Always substitute this with your chosen name! Most of the times you have to use lower case as now with the directories and filenames. &lt;br /&gt;
&lt;br /&gt;
Look up the Joomla! root directory on your test system. It depends on your server and Joomla! installation. For Wamp it might be c:\wamp\www\joomla. For XAMPP c:\xampp\htdocs\joomla. Here you&#039;ll find a modules directory where you create a subdirectory mod_yourmodule. Don&#039;t forget to use your own name! We also need a mod_yourmodule/tmpl directory.&lt;br /&gt;
&lt;br /&gt;
In this step we&#039;ll only use 3 files. mod_yourmodule.xml - the so called manifest file that controls the installation and in the module case holds any configuration options, mod_yourmodule.php is the start up file / entry point. default.php holds the code for output. The latter can be named otherwise and is also called template or layout. Somewhat confusing as template and layout is used also in other contexts.&lt;br /&gt;
&lt;br /&gt;
Now you copy mod_yourmodule.xml and mod_yourmodule.php to your path/to/joomla/modules/mod_yourmodule directory. Rename! You copy default.php to path/to/joomla/modules/mod_yourmodule/tmpl.&lt;br /&gt;
&lt;br /&gt;
After you created the 2 new directories and copied the 3 new files your Joomla path should look like below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/media&lt;br /&gt;
/modules&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /tmpl                  *new directory*&lt;br /&gt;
      default.php          *new file*&lt;br /&gt;
    mod_yourmodule.php     *new file*&lt;br /&gt;
    mod_yourmodule.xml     *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/plugins&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The modules xml file ===&lt;br /&gt;
&lt;br /&gt;
Open mod_yourmodule.xml with your editor. We&#039;ll have a look at what we have there and make some modifications.&lt;br /&gt;
&lt;br /&gt;
More information about [[Manifest_files|Manifest files]]. We will come back to this file more than once to add more tags and definitions.&lt;br /&gt;
&lt;br /&gt;
===== mod_yourmodule.xml =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;module&amp;quot; version=&amp;quot;3.3.0&amp;quot; client=&amp;quot;site&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;name&amp;gt;mod_yourmodule&amp;lt;/name&amp;gt;&lt;br /&gt;
    &amp;lt;version&amp;gt;1.0.0&amp;lt;/version&amp;gt;&lt;br /&gt;
	&amp;lt;creationDate&amp;gt;August 2014&amp;lt;/creationDate&amp;gt;&lt;br /&gt;
    &amp;lt;author&amp;gt;Joomla Doe&amp;lt;/author&amp;gt;&lt;br /&gt;
	&amp;lt;authorUrl&amp;gt;www.yourmodule.org&amp;lt;/authorUrl&amp;gt;&lt;br /&gt;
 	&amp;lt;authorEmail&amp;gt;joomla.doe@yourmodule.org&amp;lt;/authorEmail&amp;gt;&lt;br /&gt;
	&amp;lt;copyright&amp;gt;Copyright (C) 2014 Joomla Doe&amp;lt;/copyright&amp;gt;&lt;br /&gt;
	&amp;lt;license&amp;gt;GNU General Public License version 2 or later; see LICENSE.txt&amp;lt;/license&amp;gt;&lt;br /&gt;
    &amp;lt;description&amp;gt;Your own first custom module.&amp;lt;/description&amp;gt;&lt;br /&gt;
    &amp;lt;files&amp;gt;&lt;br /&gt;
        &amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
        &amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
        &amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
    &amp;lt;/files&amp;gt;&lt;br /&gt;
    &amp;lt;config&amp;gt;&lt;br /&gt;
    &amp;lt;/config&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The content of the xml file is almost self explaining. We define the extension as a module for Joomla! versions 3.3.0 and above. 3.3.3 is the latest version at the time of creating the tutorial Upgrade means that we leave to the installer program to decide, if it is a new installation or an update/upgrade. The name, the version and the date of the extension. Be extra careful with the module name. Any errors will stop the installation. We use mod_yourmodule as name and will come back to the reason in a later part. Information about the author with contact data. Copyright and license. If the module will be for your own private use only, you don&#039;t need all of it. It is however a good practice to include it.&lt;br /&gt;
&lt;br /&gt;
In the description you obviously explain what the module is supposed to do.&lt;br /&gt;
&lt;br /&gt;
In the files part you define what files and folders are included in your module. folder has the effect that all included files will be copied from your packed installation file to that directory (=folder). You don&#039;t have to include mod_yourmodule.xml here as it always will be copied.&lt;br /&gt;
&lt;br /&gt;
Comment: We did not include any index.html files. These were used to prevent users to attempt to list the content by pointing their browser to these folders. Joomla! has dropped this requirement. Acces is blocked by your .htaccess / web.config file if properly set up. The default of those files include the needed settings.&lt;br /&gt;
&lt;br /&gt;
We&#039;ll come back to &amp;amp;lt;config&amp;amp;gt; when we extend the functionality. It stays empty for now.&lt;br /&gt;
&lt;br /&gt;
Edit this file and replace the data with your own name/modulename.&lt;br /&gt;
&lt;br /&gt;
Save and close mod_yourmodule.xml&lt;br /&gt;
&lt;br /&gt;
=== The start up file ===&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll have a look at the entry point file mod_yourmodule.php.&lt;br /&gt;
&lt;br /&gt;
===== mod_yourmodule.php =====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
require JModuleHelper::getLayoutPath(&#039;mod_yourmodule&#039;, $params-&amp;gt;get(&#039;layout&#039;, &#039;default&#039;));&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Not more than this is needed for the most basic module we develop in this first tutorial part.&lt;br /&gt;
&lt;br /&gt;
You tell the system that this is php code and write a comment. You can find example comments in any Joomla! core php file or any 3.d party extension. You can add more information if you like but do not overdo. If you use functionality from another developers in the code it&#039;s a nice practice to mention that. Something like : this is a fork of mod_yourmodule by Joomla Doe. &lt;br /&gt;
&lt;br /&gt;
The line defined(... has to be included! It prevents users from running this php code from outside of Joomla!.&lt;br /&gt;
&lt;br /&gt;
The last line calls the default.php file that includes the output commands ( name without php ending ). You can see that the confusing word layout is used. Here it means a file in the tmpl folder.&lt;br /&gt;
&lt;br /&gt;
{{Tip|Do not add a php closing tag &#039; ?&amp;gt;&#039; at the end of a php file. Add an empty line at the end of files.}}&lt;br /&gt;
&lt;br /&gt;
Edit the module name and save. Do not close it if your editor allows to hold two or more files open.&lt;br /&gt;
&lt;br /&gt;
If you want to know more about Joomla! coding standards: [http://joomla.github.io/coding-standards/ joomla coding-standards] Contibutions to Joomla! core development must follow those standards.&lt;br /&gt;
&lt;br /&gt;
More for advanced developers: [[Joomla_CodeSniffer|Joomla CodeSniffer]] and [https://github.com/joomla/coding-standards/tree/master/IDE joomla/ coding-standards - IDE]&lt;br /&gt;
&lt;br /&gt;
=== The output/template/layout file ===&lt;br /&gt;
&lt;br /&gt;
The last file to edit before we enable the module for the frontend pages is the default.php&lt;br /&gt;
&lt;br /&gt;
===== default.php =====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;From your first module&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;This is the content&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the comments part - that you changed - from the former php file and paste it here, replacing the comment. After the obligatory defined(... line we close the php part with ?&amp;gt;. The rest is at your disposal. Use the knowledge you have of html code to show text on the frontpage. Alternatively you can write a very short article in the Joomla! backend, toggle the editor and copy the source code to the php file. If you do, save the article and note the article. We&#039;ll use an article as source in a later step.&lt;br /&gt;
&lt;br /&gt;
After saving the file we are ready to enable your custom module on the frontend.&lt;br /&gt;
&lt;br /&gt;
=== Install and enable the module ===&lt;br /&gt;
&lt;br /&gt;
{{Tip|Before you proceed it might be a good idea to backup your test site. Well, only in case of ...}}&lt;br /&gt;
The most simple way to backup your local server is to copy the whole web directory. It includes both your local site and the database. See path examples above. &lt;br /&gt;
&lt;br /&gt;
We do not need to create a compressed installation file (.zip) to install an extension. We&#039;ll use the Discover method.&lt;br /&gt;
&lt;br /&gt;
Go to {{rarr|Extensions,Extension Manager,Click on Discover}}, in the Extension Manager:Discover menu you click on the Discover button&lt;br /&gt;
&lt;br /&gt;
Mark your module in the list and click on the Install button. If everything went well, you&#039;ll get a message that tells you that the module was installed.&lt;br /&gt;
&lt;br /&gt;
At last you enable the module in the Module Manager. Click on New and find it in the the list. As difference to &amp;quot;normal&amp;quot; module installation the Discover method probably did not add an entry to the module instances list. The name is mod_yourmodule so you&#039;ll find it lower case sorted to the end of the list . We&#039;ll fix that in the next tutorial part.&lt;br /&gt;
&lt;br /&gt;
Info for new Joomla! users: You can create multiple instances/copies of a module. Each with different option settings. That is what you do when you click on the New button.&lt;br /&gt;
&lt;br /&gt;
Add a title, choose a module position and publish. Go to the frontend and see your first module creation. You can now modify the default.php file to get something fancy before you go on to the next step in the tutorial.&lt;br /&gt;
&lt;br /&gt;
{{Tip|To remember for ever. Do not forget to click the Menu Assignment tab in the Module Manager. Promised: You will! }}&lt;br /&gt;
&lt;br /&gt;
More about [[Module|Joomla! Modules]]&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125256</id>
		<title>User:Over/Step by step to a Joomla Module - Installation package</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125256"/>
		<updated>2014-09-08T14:46:39Z</updated>

		<summary type="html">&lt;p&gt;Over: /* mod_yourmodule.xml - Config */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to become an installable extension for any Joomla! 3.x site. e.g. after testing the functionality on your local installation you can upload and install it on your live site with a few clicks.&lt;br /&gt;
&lt;br /&gt;
=== Language files ===&lt;br /&gt;
&lt;br /&gt;
The language files hold the textstrings that are used for descriptions, field labels, field descriptions and any other static texts. You can also translate the textstrings for any language code. The default language code is en-GB, Great Britain english. In version 3 the english &amp;quot;translation&amp;quot; is in most cases loaded before any other specific language. i.e. you should always keep those files up to date.&lt;br /&gt;
&lt;br /&gt;
As in the first part of the tutorial we&#039;ll use skeleton files. In the folder, where you unzipped the downloaded file, you can find two language files, en-GB.mod_yourmodule.ini and en-GB.mod_yourmodule.sys.ini Copy those to the Joomla! en-GB language folder. path/to/joomla/language/en-GB. You can also find a language folder in the administrator/ path used for backend extensions and all plug ins.&lt;br /&gt;
&lt;br /&gt;
As always, change files named ...yourmodule... to the name you did choose. Open the first file en-GB.mod_yourmodule.ini&lt;br /&gt;
&lt;br /&gt;
===== en-GB.mod_yourmodule.ini =====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Copyright (C) 2014 Joomla Doe&lt;br /&gt;
; Translater Joomla Doe&lt;br /&gt;
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php&lt;br /&gt;
; Note : All ini files need to be saved as UTF-8 - No BOM&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE=&amp;quot;Your own module&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of my module. This one in .ini is shown when editing the module in the Module Manager. Yoü can e.g. add some tips to the confuguration and a link to a help page on your site&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the top we find some comments. As you see, you have to use ; in front of the comments. If you have friendly helpers that translate your extension, it&#039;s nice to have a line with the translators name. The use of character set UTF-8 is noted. For the language string constants you should follow the Joomla! best practice i.e. start all language constants with the extension name. &#039;&#039;&#039;The language constants have to be in upper case with _ (underscore) as divider ending with a =. The text has to be within &amp;quot; double quote.&#039;&#039;&#039; Do not use double quote within the text or you will have to find out how to use __QQ__. &#039;&#039;&#039;No line break is allowed!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
; An example with double quote&lt;br /&gt;
MOD_YOURMODULE_MY_QUOTE=&amp;quot;My value is &amp;quot;_QQ_&amp;quot;great!&amp;quot;_QQ_&amp;quot;. I like it&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is no good reference available at the time of writing. Please change this link if a better is found. [[Specification_of_language_files|Specification of language files]]&lt;br /&gt;
&lt;br /&gt;
Change the two MOD_YOURMODULE, change the first text to a &amp;quot;human&amp;quot; name of your module and change the description. Again: in one line! &#039;&#039;&#039;no line break is allowed!&#039;&#039;&#039;. If you add e.g. a link remeber &amp;quot;_QQ_&amp;quot; for double quotes. Save this file and copy the text except the description content. The second file has almost the same content at this stage. Open en-GB.mod_yourmodule.sys.ini and paste the copied text replacing the text i.e. not the description text.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of your module. This one in .sys.ini is shown when choosing a new module in the module manager and in the extension manager. Keep this shorter.&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the description and save.&lt;br /&gt;
&lt;br /&gt;
The difference between those is that the .sys.ini file is loaded in cases like module lists where no module fields are shown. We´ll see another use of the .sys.ini below.&lt;br /&gt;
&lt;br /&gt;
As promised in the first part of the tutorial, you can now see the reason for using mod_yourmodule as module name in the xml file. Go to Module Manager, click on new. You will find your module with the name from the language file. Next we will fix the description. Before you close the files copy the constant MOD_YOURMODULE_XML_DESCRIPTION.&lt;br /&gt;
&lt;br /&gt;
Open mod_yourmodule.xml from the server and find the description line. Replace the description with your copied language constant MOD_YOURMODULE_XML_DESCRIPTION.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Description ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;MOD_YOURMODULE_XML_DESCRIPTION&amp;lt;/description&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can make the same test as before in the Module Manager and you&#039;ll see that the description comes from the language files.&lt;br /&gt;
&lt;br /&gt;
=== Parameters - Options ===&lt;br /&gt;
If you choose your enabled module for edit in the Module Manager you&#039;ll se some default options under the advanced tab. Let&#039;s add some more options in the xml file and add the used language strings before we create the first installable package.&lt;br /&gt;
&lt;br /&gt;
Add the following where you find the config part. We will see more around form fields in a later tutorial part.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Config ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;config&amp;gt;&lt;br /&gt;
      &amp;lt;fields name=&amp;quot;params&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;options&amp;quot; label=&amp;quot;COM_MODULES_BASIC_FIELDSET_LABEL&amp;quot;&lt;br /&gt;
            addfieldpath=&amp;quot;/administrator/components/com_content/models/fields/modal&amp;quot;&lt;br /&gt;
	 &amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;article_id&amp;quot;&lt;br /&gt;
               type=&amp;quot;modal_article&amp;quot;&lt;br /&gt;
               default=&amp;quot;&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_DESC&amp;quot; &amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;advanced&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_css&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_js&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;layout&amp;quot;&lt;br /&gt;
               type=&amp;quot;modulelayout&amp;quot;&lt;br /&gt;
               label=&amp;quot;JFIELD_ALT_LAYOUT_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;JFIELD_ALT_MODULE_LAYOUT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;moduleclass_sfx&amp;quot;&lt;br /&gt;
               type=&amp;quot;textarea&amp;quot; rows=&amp;quot;3&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache&amp;quot;&lt;br /&gt;
               type=&amp;quot;list&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHING_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHING_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JGLOBAL_USE_GLOBAL&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;COM_MODULES_FIELD_VALUE_NOCACHING&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache_time&amp;quot;&lt;br /&gt;
               type=&amp;quot;text&amp;quot;&lt;br /&gt;
               default=&amp;quot;900&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cachemode&amp;quot;&lt;br /&gt;
               type=&amp;quot;hidden&amp;quot;&lt;br /&gt;
               default=&amp;quot;static&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;static&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
      &amp;lt;/fields&amp;gt;&lt;br /&gt;
   &amp;lt;/config&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the fieldset options we add an option field &amp;quot;article_id&amp;quot;, that we will use later. This field calls a modal window, where you can choose an article. Fieldset options is shown in the tab Options in the Module Manager. If you use a fieldset named basic you&#039;ll have those fields in the first tab. We also add some standard option fields to the &amp;quot;Advanced&amp;quot; tab. We do not have to add the text constants used in the Advanced part, since they are standard. Remains the two strings used for the article field. Well, we added two fields in the advanced tab, load_css and load_js with language strings that need to be added. We&#039;ll come back to the use of those options later. &lt;br /&gt;
&lt;br /&gt;
Follow this link to read more about [http://docs.joomla.org/Module Joomla modules and the Modules Manager]&lt;br /&gt;
&lt;br /&gt;
=== Add strings to language file ===&lt;br /&gt;
Save the xml file and open the language file. The one without .sys.&lt;br /&gt;
&lt;br /&gt;
Add the 6 strings and save.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.ini - New strings ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_DESC=&amp;quot;Choose an article to be shown by the module.&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_LABEL=&amp;quot;Article&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_DESC=&amp;quot;You can disable the modules css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL=&amp;quot;Load Css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_DESC=&amp;quot;You can disable the modules JavaScript&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_LABEL=&amp;quot;Load JavaScript&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Final change to the xml file ===&lt;br /&gt;
&lt;br /&gt;
Before we create the first installation file we will add the language tags to the xml file below the &amp;lt;/files&amp;gt; tag.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Final ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
   &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We use a folder named langs here, because we will use the folder language for a trick. If you include other language files just add lines with the correspondent language identifier.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;large-12 panel radius&amp;quot; style=&amp;quot;background-color:#fff; border:1px solid #aaa; margin:1em 0;&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;For those of you that have some knowledge of Joomla development:&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
Do not add the /language folder to the xml file. It is autoloaded. i.e. extracted and used in the installation process by default.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the xml file.&lt;br /&gt;
&lt;br /&gt;
=== Create the compressed installation file ===&lt;br /&gt;
Now we have everything to create the first version of the installation file.&lt;br /&gt;
&lt;br /&gt;
Inside the folder you created on yor local system at the start of the tutorial &#039;somewhere&#039;/j_module_tutorial/new_module you add three sub directories. langs, language and tmpl. Now you copy the files in the other direction. From the web directory to the new one. It should look something like this ( remember - yourmodule - is a placeholder for your choosen module name ):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
.../new_module&lt;br /&gt;
     /langs&lt;br /&gt;
       en-GB.mod_yourmodule.ini&lt;br /&gt;
       en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
       anyother-language.mod_yourmodule.in&lt;br /&gt;
       anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
     /language&lt;br /&gt;
       /en-GB&lt;br /&gt;
         en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
       /anyother-language&lt;br /&gt;
         anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
     /tmpl&lt;br /&gt;
       default.php&lt;br /&gt;
     mod_yourmodule.php&lt;br /&gt;
     mod_yourmodule.xml&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a last step we&#039;ll edit the .../new_module/language/en-GB/mod_yourmodule.sys.ini to show a different message at installation/upgrade.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.sys.ini - Installation message ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;Thank you for installing / update the Your own module. This module displays an article text in a module position. To activate you go to the module manager and edit this module or create a new entry. Select the article you want to show. Please visit www.mysite.com for more information. If you like it please add a review on JED.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you edit the description text to include a &amp;quot;Thanks&amp;quot; and other informations only relevant directly after the installation / upgrade this is a trick to achieve this. Only .../new_module/langs/language-codes.mod_yourmodule.sys.ini will be copied and used after the installation.&lt;br /&gt;
&lt;br /&gt;
You can find two short descriptions of alternative handling of the language files at the end of this page.&lt;br /&gt;
&lt;br /&gt;
Now we compress the files. The Zip type is recommended as it has native support by most systems. In Windows you go to the .../new_module folder. Mark the included folders and files, right click and choose {{rarr|Send to,ZIP compressed folder}}.&lt;br /&gt;
&lt;br /&gt;
Rename the .zip file to mod_yourmodule_1_0_0-a1.zip i.e. including the version number and an arcive number. With an archive number included you can easily restore to a tutorial step. You should better move this file to another folder. It is easy forgotten NOT to include it, the next time you create a zipped file.&lt;br /&gt;
&lt;br /&gt;
You made a backup before starting the tutorial? Well, only in case of ...&lt;br /&gt;
&lt;br /&gt;
First you uninstall the module to get a complete new installation {{rarr|Extensions,Manager,Manage}} Look up the module. Filter e.g. Location = Site, Type=Module and/or name.&lt;br /&gt;
&lt;br /&gt;
When the module is uninstalled you go to Install, browse to your installation zip file and click the Upload &amp;amp;amp; Install button. You&#039;ll see the description you edited as installation message. Go to the Module Manager. This time you should find an entry in the Module list. Choose this and enable it, as you did after the Discover in the first part of the tutorial. You can also see that the description is the one from your .ini file. To check the description from .sys.ini click on NEW module. This is not the one you saw directly after the installation.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this part of the module tutorial. The next part will show you how to retrieve data and add some Css styling to your module.&lt;br /&gt;
&lt;br /&gt;
=== Alternative language files  handling ===&lt;br /&gt;
&lt;br /&gt;
For both alternatives you have to add all language files to subfolders in the /language folder. Be aware that the folder name is mandatory! &lt;br /&gt;
&lt;br /&gt;
You can use the language files from the /langs folder in the example above. Do not add a long description to the .sys.ini files, as it will be used for the module lists. Of course you have to remove the /langs folder, if you want to test by changing the example above.&lt;br /&gt;
&lt;br /&gt;
Resulting folder:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/language&lt;br /&gt;
  /en-GB&lt;br /&gt;
    en-GB.mod_yourmodule.ini&lt;br /&gt;
    en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
  /anyother-language&lt;br /&gt;
    anyother-language.mod_yourmodule.ini&lt;br /&gt;
    anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 1. Easiest way  ====&lt;br /&gt;
&lt;br /&gt;
Add a folder tag to the files area in the xml file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;folder&amp;gt;language&amp;lt;/folder&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The folder will be stored in the extensions folder and no files in the core language folder.&lt;br /&gt;
ALL files are copied, not only the ones for installed languages.&lt;br /&gt;
&lt;br /&gt;
==== 2. Traditional way  ====&lt;br /&gt;
&lt;br /&gt;
Add all single language files to the languages tag in the xml file. Be aware of the extra folder name required (= language tag).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;language&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt; &lt;br /&gt;
  &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files are saved to the core language folder in the traditional way.&lt;br /&gt;
Only the files for installed languages are copied.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125255</id>
		<title>User:Over/Step by step to a Joomla Module - Installation package</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125255"/>
		<updated>2014-09-08T14:36:50Z</updated>

		<summary type="html">&lt;p&gt;Over: /* mod_yourmodule.sys.ini - Installation message */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to become an installable extension for any Joomla! 3.x site. e.g. after testing the functionality on your local installation you can upload and install it on your live site with a few clicks.&lt;br /&gt;
&lt;br /&gt;
=== Language files ===&lt;br /&gt;
&lt;br /&gt;
The language files hold the textstrings that are used for descriptions, field labels, field descriptions and any other static texts. You can also translate the textstrings for any language code. The default language code is en-GB, Great Britain english. In version 3 the english &amp;quot;translation&amp;quot; is in most cases loaded before any other specific language. i.e. you should always keep those files up to date.&lt;br /&gt;
&lt;br /&gt;
As in the first part of the tutorial we&#039;ll use skeleton files. In the folder, where you unzipped the downloaded file, you can find two language files, en-GB.mod_yourmodule.ini and en-GB.mod_yourmodule.sys.ini Copy those to the Joomla! en-GB language folder. path/to/joomla/language/en-GB. You can also find a language folder in the administrator/ path used for backend extensions and all plug ins.&lt;br /&gt;
&lt;br /&gt;
As always, change files named ...yourmodule... to the name you did choose. Open the first file en-GB.mod_yourmodule.ini&lt;br /&gt;
&lt;br /&gt;
===== en-GB.mod_yourmodule.ini =====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Copyright (C) 2014 Joomla Doe&lt;br /&gt;
; Translater Joomla Doe&lt;br /&gt;
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php&lt;br /&gt;
; Note : All ini files need to be saved as UTF-8 - No BOM&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE=&amp;quot;Your own module&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of my module. This one in .ini is shown when editing the module in the Module Manager. Yoü can e.g. add some tips to the confuguration and a link to a help page on your site&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the top we find some comments. As you see, you have to use ; in front of the comments. If you have friendly helpers that translate your extension, it&#039;s nice to have a line with the translators name. The use of character set UTF-8 is noted. For the language string constants you should follow the Joomla! best practice i.e. start all language constants with the extension name. &#039;&#039;&#039;The language constants have to be in upper case with _ (underscore) as divider ending with a =. The text has to be within &amp;quot; double quote.&#039;&#039;&#039; Do not use double quote within the text or you will have to find out how to use __QQ__. &#039;&#039;&#039;No line break is allowed!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
; An example with double quote&lt;br /&gt;
MOD_YOURMODULE_MY_QUOTE=&amp;quot;My value is &amp;quot;_QQ_&amp;quot;great!&amp;quot;_QQ_&amp;quot;. I like it&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is no good reference available at the time of writing. Please change this link if a better is found. [[Specification_of_language_files|Specification of language files]]&lt;br /&gt;
&lt;br /&gt;
Change the two MOD_YOURMODULE, change the first text to a &amp;quot;human&amp;quot; name of your module and change the description. Again: in one line! &#039;&#039;&#039;no line break is allowed!&#039;&#039;&#039;. If you add e.g. a link remeber &amp;quot;_QQ_&amp;quot; for double quotes. Save this file and copy the text except the description content. The second file has almost the same content at this stage. Open en-GB.mod_yourmodule.sys.ini and paste the copied text replacing the text i.e. not the description text.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of your module. This one in .sys.ini is shown when choosing a new module in the module manager and in the extension manager. Keep this shorter.&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the description and save.&lt;br /&gt;
&lt;br /&gt;
The difference between those is that the .sys.ini file is loaded in cases like module lists where no module fields are shown. We´ll see another use of the .sys.ini below.&lt;br /&gt;
&lt;br /&gt;
As promised in the first part of the tutorial, you can now see the reason for using mod_yourmodule as module name in the xml file. Go to Module Manager, click on new. You will find your module with the name from the language file. Next we will fix the description. Before you close the files copy the constant MOD_YOURMODULE_XML_DESCRIPTION.&lt;br /&gt;
&lt;br /&gt;
Open mod_yourmodule.xml from the server and find the description line. Replace the description with your copied language constant MOD_YOURMODULE_XML_DESCRIPTION.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Description ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;MOD_YOURMODULE_XML_DESCRIPTION&amp;lt;/description&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can make the same test as before in the Module Manager and you&#039;ll see that the description comes from the language files.&lt;br /&gt;
&lt;br /&gt;
=== Parameters - Options ===&lt;br /&gt;
If you choose your enabled module for edit in the Module Manager you&#039;ll se some default options under the advanced tab. Let&#039;s add some more options in the xml file and add the used language strings before we create the first installable package.&lt;br /&gt;
&lt;br /&gt;
Add the following where you find the config part. We will see more around form fields in a later tutorial part.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Config ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;config&amp;gt;&lt;br /&gt;
      &amp;lt;fields name=&amp;quot;params&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;options&amp;quot; label=&amp;quot;COM_MODULES_BASIC_FIELDSET_LABEL&amp;quot;&lt;br /&gt;
            addfieldpath=&amp;quot;/administrator/components/com_content/models/fields/modal&amp;quot;&lt;br /&gt;
	 &amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;article_id&amp;quot;&lt;br /&gt;
               type=&amp;quot;modal_article&amp;quot;&lt;br /&gt;
               default=&amp;quot;&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_DESC&amp;quot; &amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;advanced&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_css&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_js&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;layout&amp;quot;&lt;br /&gt;
               type=&amp;quot;modulelayout&amp;quot;&lt;br /&gt;
               label=&amp;quot;JFIELD_ALT_LAYOUT_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;JFIELD_ALT_MODULE_LAYOUT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;moduleclass_sfx&amp;quot;&lt;br /&gt;
               type=&amp;quot;textarea&amp;quot; rows=&amp;quot;3&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache&amp;quot;&lt;br /&gt;
               type=&amp;quot;list&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHING_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHING_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JGLOBAL_USE_GLOBAL&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;COM_MODULES_FIELD_VALUE_NOCACHING&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache_time&amp;quot;&lt;br /&gt;
               type=&amp;quot;text&amp;quot;&lt;br /&gt;
               default=&amp;quot;900&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cachemode&amp;quot;&lt;br /&gt;
               type=&amp;quot;hidden&amp;quot;&lt;br /&gt;
               default=&amp;quot;static&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;static&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
      &amp;lt;/fields&amp;gt;&lt;br /&gt;
   &amp;lt;/config&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the fieldset options we add an option field &amp;quot;article_id&amp;quot; that we will use later. This field calls a modal window where you can choose an article. Fieldset options is shown in the tab Options in the Module Manager. If you use a fieldset named basic you&#039;ll have those fields in the first tab. We also add some standard option fields to the &amp;quot;Advanced&amp;quot; tab. We do not have to add the text constants used in the Advanced part since they are standard. Remains the two strings used for the article field. Well, we added two fields in the advanced tab, load_css and load_js with language strings that need to be added. We&#039;ll come back to the use of those options later. &lt;br /&gt;
&lt;br /&gt;
Follow this link to read more about [http://docs.joomla.org/Module Joomla modules and the Modules Manager]&lt;br /&gt;
&lt;br /&gt;
=== Add strings to language file ===&lt;br /&gt;
Save the xml file and open the language file. The one without .sys.&lt;br /&gt;
&lt;br /&gt;
Add the 6 strings and save.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.ini - New strings ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_DESC=&amp;quot;Choose an article to be shown by the module.&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_LABEL=&amp;quot;Article&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_DESC=&amp;quot;You can disable the modules css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL=&amp;quot;Load Css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_DESC=&amp;quot;You can disable the modules JavaScript&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_LABEL=&amp;quot;Load JavaScript&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Final change to the xml file ===&lt;br /&gt;
&lt;br /&gt;
Before we create the first installation file we will add the language tags to the xml file below the &amp;lt;/files&amp;gt; tag.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Final ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
   &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We use a folder named langs here, because we will use the folder language for a trick. If you include other language files just add lines with the correspondent language identifier.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;large-12 panel radius&amp;quot; style=&amp;quot;background-color:#fff; border:1px solid #aaa; margin:1em 0;&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;For those of you that have some knowledge of Joomla development:&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
Do not add the /language folder to the xml file. It is autoloaded. i.e. extracted and used in the installation process by default.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the xml file.&lt;br /&gt;
&lt;br /&gt;
=== Create the compressed installation file ===&lt;br /&gt;
Now we have everything to create the first version of the installation file.&lt;br /&gt;
&lt;br /&gt;
Inside the folder you created on yor local system at the start of the tutorial &#039;somewhere&#039;/j_module_tutorial/new_module you add three sub directories. langs, language and tmpl. Now you copy the files in the other direction. From the web directory to the new one. It should look something like this ( remember - yourmodule - is a placeholder for your choosen module name ):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
.../new_module&lt;br /&gt;
     /langs&lt;br /&gt;
       en-GB.mod_yourmodule.ini&lt;br /&gt;
       en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
       anyother-language.mod_yourmodule.in&lt;br /&gt;
       anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
     /language&lt;br /&gt;
       /en-GB&lt;br /&gt;
         en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
       /anyother-language&lt;br /&gt;
         anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
     /tmpl&lt;br /&gt;
       default.php&lt;br /&gt;
     mod_yourmodule.php&lt;br /&gt;
     mod_yourmodule.xml&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a last step we&#039;ll edit the .../new_module/language/en-GB/mod_yourmodule.sys.ini to show a different message at installation/upgrade.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.sys.ini - Installation message ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;Thank you for installing / update the Your own module. This module displays an article text in a module position. To activate you go to the module manager and edit this module or create a new entry. Select the article you want to show. Please visit www.mysite.com for more information. If you like it please add a review on JED.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you edit the description text to include a &amp;quot;Thanks&amp;quot; and other informations only relevant directly after the installation / upgrade this is a trick to achieve this. Only .../new_module/langs/language-codes.mod_yourmodule.sys.ini will be copied and used after the installation.&lt;br /&gt;
&lt;br /&gt;
You can find two short descriptions of alternative handling of the language files at the end of this page.&lt;br /&gt;
&lt;br /&gt;
Now we compress the files. The Zip type is recommended as it has native support by most systems. In Windows you go to the .../new_module folder. Mark the included folders and files, right click and choose {{rarr|Send to,ZIP compressed folder}}.&lt;br /&gt;
&lt;br /&gt;
Rename the .zip file to mod_yourmodule_1_0_0-a1.zip i.e. including the version number and an arcive number. With an archive number included you can easily restore to a tutorial step. You should better move this file to another folder. It is easy forgotten NOT to include it, the next time you create a zipped file.&lt;br /&gt;
&lt;br /&gt;
You made a backup before starting the tutorial? Well, only in case of ...&lt;br /&gt;
&lt;br /&gt;
First you uninstall the module to get a complete new installation {{rarr|Extensions,Manager,Manage}} Look up the module. Filter e.g. Location = Site, Type=Module and/or name.&lt;br /&gt;
&lt;br /&gt;
When the module is uninstalled you go to Install, browse to your installation zip file and click the Upload &amp;amp;amp; Install button. You&#039;ll see the description you edited as installation message. Go to the Module Manager. This time you should find an entry in the Module list. Choose this and enable it, as you did after the Discover in the first part of the tutorial. You can also see that the description is the one from your .ini file. To check the description from .sys.ini click on NEW module. This is not the one you saw directly after the installation.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this part of the module tutorial. The next part will show you how to retrieve data and add some Css styling to your module.&lt;br /&gt;
&lt;br /&gt;
=== Alternative language files  handling ===&lt;br /&gt;
&lt;br /&gt;
For both alternatives you have to add all language files to subfolders in the /language folder. Be aware that the folder name is mandatory! &lt;br /&gt;
&lt;br /&gt;
You can use the language files from the /langs folder in the example above. Do not add a long description to the .sys.ini files, as it will be used for the module lists. Of course you have to remove the /langs folder, if you want to test by changing the example above.&lt;br /&gt;
&lt;br /&gt;
Resulting folder:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/language&lt;br /&gt;
  /en-GB&lt;br /&gt;
    en-GB.mod_yourmodule.ini&lt;br /&gt;
    en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
  /anyother-language&lt;br /&gt;
    anyother-language.mod_yourmodule.ini&lt;br /&gt;
    anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 1. Easiest way  ====&lt;br /&gt;
&lt;br /&gt;
Add a folder tag to the files area in the xml file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;folder&amp;gt;language&amp;lt;/folder&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The folder will be stored in the extensions folder and no files in the core language folder.&lt;br /&gt;
ALL files are copied, not only the ones for installed languages.&lt;br /&gt;
&lt;br /&gt;
==== 2. Traditional way  ====&lt;br /&gt;
&lt;br /&gt;
Add all single language files to the languages tag in the xml file. Be aware of the extra folder name required (= language tag).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;language&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt; &lt;br /&gt;
  &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files are saved to the core language folder in the traditional way.&lt;br /&gt;
Only the files for installed languages are copied.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_A_form_and_ajax&amp;diff=125254</id>
		<title>User:Over/Step by step to a Joomla Module - A form and ajax</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_A_form_and_ajax&amp;diff=125254"/>
		<updated>2014-09-08T14:23:42Z</updated>

		<summary type="html">&lt;p&gt;Over: /* message.xml */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{underconstruction}}&lt;br /&gt;
&lt;br /&gt;
{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this part of the tutorial we will use the form functionality of Joomla!. In a second step we&#039;ll add the Joomla! Ajax functionality to the module. If you want to keep the custom module you created up till now, you should use the knowledge you&#039;ve got from this tutorial and fork it. i.e. you copy all the files to a new local folder and change all filenames to a new name. Then you change all texts in the files including the old module name to a new at your choise, create an installation file and install the new module. We will still use yourmodule as name, so you&#039;ll have to adopt your own as before.&lt;br /&gt;
&lt;br /&gt;
Ajax = short for asynchronous JavaScript + XML&lt;br /&gt;
{{Tip|We will not mention the name adoption anymore and be less specific about file update.}}&lt;br /&gt;
&lt;br /&gt;
If you have a MVC component related to your module, it&#039;s easier and recommended to include the form functionality a.k.a. JForm by using the components methods. We&#039;ll add it without a component in this example.&lt;br /&gt;
&lt;br /&gt;
Why use JForm for html forms? You get a lot for &amp;quot;free&amp;quot;, like fields html code, client and server side validation.&lt;br /&gt;
&lt;br /&gt;
We first need a xml form declaration. In the folder where you unzipped the downloaded file you can find a models folder. Copy this to your modules web &#039;root&#039; folder. A module doesn&#039;t follow the MVC pattern, but let us use models as folder name. For a component you&#039;ll find forms, fields and rules in this path. You can find examples of custom fields and rules in those folders.&lt;br /&gt;
&lt;br /&gt;
=== The form ===&lt;br /&gt;
Open models/forms/yourmodule_form.xml for edit.&lt;br /&gt;
&lt;br /&gt;
==== message.xml ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;form&amp;gt;&lt;br /&gt;
   &amp;lt;fieldset addfieldpath=&amp;quot;modules/mod_yourmodule/models/fields&amp;quot;&lt;br /&gt;
             addrulepath=&amp;quot;modules/mod_yourmodule/models/rules&amp;quot;&amp;gt;  &lt;br /&gt;
      &amp;lt;field name=&amp;quot;subject&amp;quot;&lt;br /&gt;
         type=&amp;quot;text&amp;quot;&lt;br /&gt;
         size=&amp;quot;60&amp;quot;&lt;br /&gt;
         description=&amp;quot;MOD_YOURMODULE_MESSAGE_SUBJECT_DESC&amp;quot;&lt;br /&gt;
         label=&amp;quot;MOD_YOURMODULE_MESSAGE_SUBJECT_LABEL&amp;quot;&lt;br /&gt;
         filter=&amp;quot;string&amp;quot;&lt;br /&gt;
         validate=&amp;quot;yourmessagesubject&amp;quot;&lt;br /&gt;
         required=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;field name=&amp;quot;message&amp;quot;&lt;br /&gt;
         type=&amp;quot;textarea&amp;quot;&lt;br /&gt;
         cols=&amp;quot;50&amp;quot;&lt;br /&gt;
         rows=&amp;quot;10&amp;quot;&lt;br /&gt;
         description=&amp;quot;MOD_YOURMODULE_ENTER_MESSAGE_DESC&amp;quot;&lt;br /&gt;
         label=&amp;quot;MOD_YOURMODULE_ENTER_MESSAGE_LABEL&amp;quot;&lt;br /&gt;
         filter=&amp;quot;safehtml&amp;quot;&lt;br /&gt;
         validate=&amp;quot;yourmessage&amp;quot;&lt;br /&gt;
         required=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To be able to use our own fields and rules we add &#039;addfieldpath&#039; and &#039;addrulepath&#039;. Explaning the details of the declarations is outside the scope of this tutorial. Only so far: we add two fields &#039;subject&#039; and &#039;message&#039;. As you can see we use the same xml pattern as is used for the module options. Change the labels and descriptions. Do &#039;&#039;&#039;NOT&#039;&#039;&#039; change &#039;your&#039; in the validate lines or you have to edit the rules files. &lt;br /&gt;
&lt;br /&gt;
More about [[Form_field|Form fields]]&lt;br /&gt;
&lt;br /&gt;
You can find examples of form declarations in the core components. e,g. /administrator/com_content/models/forms/article.xml&lt;br /&gt;
&lt;br /&gt;
=== The language strings ===&lt;br /&gt;
&lt;br /&gt;
We have to add the language strings to the .ini file&lt;br /&gt;
&lt;br /&gt;
==== en-GB.mod_yourmodule.ini Form texts ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_MESSAGE_SUBJECT_DESC=&amp;quot;The subject of yor message&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_MESSAGE_SUBJECT_LABEL=&amp;quot;Subject&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_ENTER_MESSAGE_DESC=&amp;quot;Add your message&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_ENTER_MESSAGE_LABEL=&amp;quot;Message&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add the form to the output ===&lt;br /&gt;
&lt;br /&gt;
==== default.php With a form ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;A form your module&amp;lt;/h3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;form id=&amp;quot;mod_yourmodule_&amp;lt;?php echo $module-&amp;gt;id;?&amp;gt;&amp;quot; action=&amp;quot;&amp;lt;?php echo JRoute::_(&#039;index.php&#039;); ?&amp;gt;&amp;quot; method=&amp;quot;post&amp;quot; class=&amp;quot;form-validate&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;fieldset class=&amp;quot;well&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;?php&lt;br /&gt;
      echo $form-&amp;gt;renderField(&#039;subject&#039;);&lt;br /&gt;
      echo $form-&amp;gt;renderField(&#039;message&#039;);&lt;br /&gt;
&lt;br /&gt;
   if (!$messageSent)&lt;br /&gt;
   {&lt;br /&gt;
      echo &#039;&amp;lt;button class=&amp;quot;btn btn-primary validate&amp;quot; type=&amp;quot;submit&amp;quot;&amp;gt;&#039;.JText::_(&#039;JSUBMIT&#039;).&#039;&amp;lt;/button&amp;gt;&#039;;&lt;br /&gt;
      echo &#039;&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;mod_yourmodule&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&#039;;&lt;br /&gt;
      echo JHtml::_(&#039;form.token&#039;);&lt;br /&gt;
	}&lt;br /&gt;
	?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/fieldset&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will make some changes to this code, when we add Ajax handling to the module. Add this if you first want to test the form without Ajax.&lt;br /&gt;
&lt;br /&gt;
=== Load and use the model ===&lt;br /&gt;
&lt;br /&gt;
We load the message model and use it to get our form.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.php Use a model  ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
   defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
   //the class suffix from parameter&lt;br /&gt;
   $moduleclass_sfx = htmlspecialchars($params-&amp;gt;get(&#039;moduleclass_sfx&#039;));&lt;br /&gt;
&lt;br /&gt;
   $jinput = JFactory::getApplication()-&amp;gt;input;&lt;br /&gt;
&lt;br /&gt;
   $messageSent = $jinput-&amp;gt;post-&amp;gt;get( &#039;mod_yourmodule&#039;, 0, &#039;INT&#039;);&lt;br /&gt;
&lt;br /&gt;
   if ($messageSent)&lt;br /&gt;
   {&lt;br /&gt;
      //check the security token&lt;br /&gt;
      JSession::checkToken() or jexit(JText::_( &#039;JINVALID_TOKEN&#039; ));&lt;br /&gt;
&lt;br /&gt;
      $data     = $jinput-&amp;gt;post-&amp;gt;get( &#039;jform&#039;, array(), &#039;ARRAY&#039; );&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Include the helper that handles the data&lt;br /&gt;
   JLoader::import( &#039;helper&#039;,JPATH_ROOT .&#039;/modules/mod_yourmodule&#039; );&lt;br /&gt;
&lt;br /&gt;
   // Include the model that provide the form functionality&lt;br /&gt;
   JLoader::import( &#039;message&#039;,JPATH_ROOT .&#039;/modules/mod_yourmodule/models&#039; );&lt;br /&gt;
&lt;br /&gt;
   $model = JModelLegacy::getInstance( &#039;Message&#039;, &#039;YourmoduleModel&#039;, array(&#039;ignore_request&#039; =&amp;gt; true));&lt;br /&gt;
&lt;br /&gt;
   $form = $model-&amp;gt;getForm( array() , $loadData = true);&lt;br /&gt;
&lt;br /&gt;
   if ($messageSent)&lt;br /&gt;
   {&lt;br /&gt;
&lt;br /&gt;
      // Test whether the data is valid.&lt;br /&gt;
      $validData = $model-&amp;gt;validate( $form, $data );&lt;br /&gt;
&lt;br /&gt;
      // Check for validation errors.&lt;br /&gt;
      if ( $validData === false )&lt;br /&gt;
      {&lt;br /&gt;
         JFactory::getApplication()-&amp;gt;enqueueMessage($model-&amp;gt;getError(), &#039;error&#039;);&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
         JFactory::getApplication()-&amp;gt;enqueueMessage(&#039;Thanks for sending us a message&#039;);&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
require JModuleHelper::getLayoutPath(&#039;mod_yourmodule&#039;, $params-&amp;gt;get(&#039;layout&#039;, &#039;default&#039;));&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will make some changes to this code as well, when we add Ajax handling to the module. Add this if you first want to test the form without Ajax.&lt;br /&gt;
&lt;br /&gt;
If you chose to change the code, you should now see a submitable form in your module position.&lt;br /&gt;
&lt;br /&gt;
=== Add Ajax functionality ===&lt;br /&gt;
&lt;br /&gt;
We remind you of the best practice to use a component for Ajax response. Since Joomla! version 3.2 a new component com_ajax is included in the Joomla! package. If you don&#039;t have a component, you can use that to get more secure handling for modules and plugins. We will use this interface here.&lt;br /&gt;
&lt;br /&gt;
Read more [[Using_Joomla_Ajax_Interface|Using Joomla Ajax Interface]]. You can also follow the examples from that document.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125253</id>
		<title>User:Over/Step by step to a Joomla Module - Data retrieval and styling</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125253"/>
		<updated>2014-09-08T14:11:05Z</updated>

		<summary type="html">&lt;p&gt;Over: /* helper.php - The sql commands */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to retrieve data from a database table in two ways, direct access to a table and using a components methods. You have to have installed the module you created in former parts of the tutorial, before you start to follow this part.&lt;br /&gt;
&lt;br /&gt;
=== Data retrieval ===&lt;br /&gt;
&lt;br /&gt;
As in the previous parts you copy a skeleton file to your module folder in your Joomla path of the server. This time you copy the helper.php file to the &amp;quot;root&amp;quot; of the module.&lt;br /&gt;
&lt;br /&gt;
==== helper.php ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
abstract class ModYourmoduleHelper&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
		//we will add some code here&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The top of the file looks like any other of our php files. Copy your own comment lines from one of the php files you have edited in the former parts of the tutorial. Then we have a class definition with a name following a convention you as well should follow. Mod + The module name + Helper. A comment block follows describing what the following function does. We will add our code within the function ( in developer language called method ). You have to read the coding standards or have a look in any Joomla! core php file to learn more about coding and commenting conventions.&lt;br /&gt;
&lt;br /&gt;
We will use an article to have a litle more dynamic data example. If you didn&#039;t create an article earlier in this tutorial series do that now. Keep it short as it&#039;s only an example. In the Module Manager you open your module and under the option tab you choose your article example. You see the title but actually the article id number is stored as parameter value.&lt;br /&gt;
&lt;br /&gt;
In the first example we&#039;ll get the article text by sending sql statements to the Joomla! database API.&lt;br /&gt;
&lt;br /&gt;
==== helper.php - The sql commands ====&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		//get the users authorisations&lt;br /&gt;
		$user       = JFactory::getUser();&lt;br /&gt;
		$groups     = implode(&#039;,&#039;, $user-&amp;gt;getAuthorisedViewLevels());&lt;br /&gt;
&lt;br /&gt;
		$db = JFactory::getDbo();&lt;br /&gt;
   		//get a db query object&lt;br /&gt;
		$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
		//select article id, title and introtext&lt;br /&gt;
		$query-&amp;gt;select(&lt;br /&gt;
			array(&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.id&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.title&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.introtext&#039;),&lt;br /&gt;
				)&lt;br /&gt;
		);&lt;br /&gt;
   		//from the article table&lt;br /&gt;
		$query-&amp;gt;from($db-&amp;gt;quoteName(&#039;#__content&#039;, &#039;a&#039;));&lt;br /&gt;
		//id from parameter, we cast to integer&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;id&#039;) . &#039; = &#039;. (int) $id);&lt;br /&gt;
		// Only return if published&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;a.state&#039;) . &#039; = 1 &#039;);&lt;br /&gt;
		//and user is authorised to read&lt;br /&gt;
                $query-&amp;gt;where($this-&amp;gt;db-&amp;gt;quoteName(&#039;a.access&#039;) . &#039; IN (&#039; . $groups . &#039;)&#039;);&lt;br /&gt;
&lt;br /&gt;
		//uncomment this line to see the query string&lt;br /&gt;
		//echo $query;&lt;br /&gt;
&lt;br /&gt;
		$db-&amp;gt;setQuery($query);&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
	   		//get the article&lt;br /&gt;
			$result = $db-&amp;gt;loadObject();&lt;br /&gt;
		}&lt;br /&gt;
   		//check error&lt;br /&gt;
		catch (RuntimeException $e)&lt;br /&gt;
		{&lt;br /&gt;
			//this is a module so we skip it if there are errors&lt;br /&gt;
			// in other cases we would show a message&lt;br /&gt;
			//$app = JFactory::getApplication();&lt;br /&gt;
			//$app-&amp;gt;enqueueMessage($e-&amp;gt;getMessage(), &#039;error&#039;);&lt;br /&gt;
&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $result;&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the brief comments in the text about what we are doing here. &lt;br /&gt;
&lt;br /&gt;
Important security issue: use $db-&amp;gt;quote($field_value) to avoid so called &amp;quot;sql-injections&amp;quot; for none integer or float variables. Be very careful when you build sql queries. &lt;br /&gt;
&lt;br /&gt;
db-&amp;gt;quoteName(&#039;field_name&#039;) escapes the name database dependent. We can&#039;t describe more details to Joomla! sql queries within this tutorial. More in [http://docs.joomla.org/Accessing_the_database_using_JDatabase Accessing the database using JDatabase]&lt;br /&gt;
&lt;br /&gt;
As this is a module we don&#039;t show errormessages to the user. If there are errors the page will still be ok.&lt;br /&gt;
&lt;br /&gt;
Copy the code to your helper.php replacing the method ( = function ) getData.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The helper file is loaded and run from mod_yourmodule.php. Open it and add the following between defined(... and require.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.php - Load helper class ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    // Include the helper file that provide the data&lt;br /&gt;
   require __DIR__ . &#039;/helper.php&#039;;&lt;br /&gt;
&lt;br /&gt;
   //the class suffix from parameter&lt;br /&gt;
   $moduleclass_sfx = htmlspecialchars($params-&amp;gt;get(&#039;moduleclass_sfx&#039;));&lt;br /&gt;
 &lt;br /&gt;
  if ( !$article = ModYourmoduleHelper::getData($params))&lt;br /&gt;
   {&lt;br /&gt;
      //if error or article not found skip this module&lt;br /&gt;
      return false;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //uncomment this line to see the available fields&lt;br /&gt;
   //var_dump($article);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the same time we get the class suffix from the parameter. Explained below.&lt;br /&gt;
Now that you have the article data, we will change the output file to show it. Remember? /tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
==== default.php - Show article ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After defined(... and the php closing tab we change the html. We use embedded php code to echo the title and the introtext. We add a module specific class $moduleclass sfx to the div tag. $moduleclass sfx is the class suffix the user can add in the Module Manager -&amp;amp;gt; tab Advanced. This can be used for Css styling if multiple instances of the same module are enabled. e.g. you can test to reuse your module by choosing another article. We will style them in the next step.&lt;br /&gt;
&lt;br /&gt;
=== Css styling ===&lt;br /&gt;
Best practice on a website is to &#039;&#039;&#039;try&#039;&#039;&#039; to keep all css styling in one file. As you don&#039;t know if the users template shows your module as designed, you have to include a css file. Not really for what we have above, but in a tutorial we do as if. You should use the parameters we created in a former part, to let the user of the module exclude your css. Described in the Overrides part of the tutorial.&lt;br /&gt;
&lt;br /&gt;
We will not only prepare for loading css but also for images and javascript. Best practice is to store those files in subfolders of the Joomla media folder. Please don&#039;t ask why this folder was named media.&lt;br /&gt;
&lt;br /&gt;
Create folder path/to/your/joomla/media/mod_yourmodule. In the folder where you unpacked the tutorial zip file you&#039;ll find a media folder. Open this and copy all three subfolders to the new folder in your web folder. It should result in something like this &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/logs&lt;br /&gt;
/media&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /css                   *new directory*&lt;br /&gt;
      yourmodule.css       *new file*&lt;br /&gt;
    /images                *new directory*&lt;br /&gt;
      doc.png              *new file*&lt;br /&gt;
      yourmodule-logo.png  *new file*&lt;br /&gt;
    /js                    *new directory*&lt;br /&gt;
      yourmodule.js        *new file*&lt;br /&gt;
      yourmodule_ajax.js   *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/modules&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Did you use your module name? You don´t have to, but it´s a good practice to use distinct names.&lt;br /&gt;
&lt;br /&gt;
=== Add Css file  ===&lt;br /&gt;
&lt;br /&gt;
We include the module specific css file to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
==== default.php - Include Css file and image ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div class=&amp;quot;row text-center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;?php echo JHtml::image(&#039;mod_yourmodule/yourmodule-logo.png&#039;, &#039;Yourmodule logo&#039;, &#039;&#039;, true, false );?&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this code added yourmodule.css will be loaded from the path media/mod_yourmodule/css/&lt;br /&gt;
Be aware of the missing /css/ ! This is added by Joomla. The image will be loaded from the path media/mod_yourmodule/images/.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s test that the css is working by adding a few lines to the yourmodule.css file. Open it with the editor and add e.g. those lines that change text color. Do we have to mention the module name that was used as css class?&lt;br /&gt;
&lt;br /&gt;
==== yourmodule.css ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
.yourmodule h4{&lt;br /&gt;
	color: #08c;&lt;br /&gt;
}&lt;br /&gt;
.yourmodule p {&lt;br /&gt;
	color: #005580;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On your frontend page the colors should have changed and an image added. Have a look! Be aware that your browser may have cached the css.&lt;br /&gt;
&lt;br /&gt;
=== Update the xml and the zip file  ===&lt;br /&gt;
&lt;br /&gt;
Now we have to add the new files to the xml file and create an updated installation zip file.&lt;br /&gt;
&lt;br /&gt;
Add the helper.php and the special media tag to the xml file.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add helper.php ====&lt;br /&gt;
&lt;br /&gt;
Add helper.php to the files tag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;files&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;helper.php&amp;lt;/filename&amp;gt; &lt;br /&gt;
		&amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add media folder ====&lt;br /&gt;
&lt;br /&gt;
Add the media tag between files and languages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
	&amp;lt;media destination=&amp;quot;mod_yourmodule&amp;quot; folder=&amp;quot;media&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;css&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;images&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;js&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/media&amp;gt;&lt;br /&gt;
	&amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== Create the installation file ===&lt;br /&gt;
&lt;br /&gt;
Now you copy &#039;&#039;&#039;all&#039;&#039;&#039; module files from the server to the path &#039;somewhere&#039;/j_module_tutorial/new_module as in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
Create a new folder &#039;media&#039; and copy the three folders from media/mod_yourmodule.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  .../new_module&lt;br /&gt;
      /langs&lt;br /&gt;
        en-GB.mod_yourmodule.ini&lt;br /&gt;
        en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        anyother-language.mod_yourmodule.in&lt;br /&gt;
        anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /language&lt;br /&gt;
        /en-GB&lt;br /&gt;
          en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        /anyother-language&lt;br /&gt;
          anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /media&lt;br /&gt;
        /css&lt;br /&gt;
          yourmodule.css&lt;br /&gt;
        /images&lt;br /&gt;
          doc.png&lt;br /&gt;
          yourmodule-logo.png&lt;br /&gt;
        /js&lt;br /&gt;
          yourmodule.js&lt;br /&gt;
      /tmpl&lt;br /&gt;
        default.php&lt;br /&gt;
      mod_yourmodule.php&lt;br /&gt;
      mod_yourmodule.xml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the compressed installation zip file as described in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this tutorial. Below we describe an alternative for data retrieval.&lt;br /&gt;
&lt;br /&gt;
=== Use a component for data retrieval ===&lt;br /&gt;
&lt;br /&gt;
Below is an alternative to using direct sql. You can use the methods provided by a component to retrieve the data. If you develop your own component, you can prepare methods for reuse, otherwise you can try to find a method in a components models to retrieve the data you want. Here we reuse the getItem method of the content component ( articles ). In this case you get all article data returned. If you use a lot of modules of this type on the same page, be a little aware of momory usage. If you want to test it, you only have to replace the getData method in helper.php.&lt;br /&gt;
&lt;br /&gt;
To see the data available you can uncomment the var_dump line in mod_yourmodule.php.&lt;br /&gt;
&lt;br /&gt;
==== helper.php Use of component ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model = JModelLegacy::getInstance(&#039;Article&#039;, &#039;ContentModel&#039;, array(&#039;ignore_request&#039; =&amp;gt; true));&lt;br /&gt;
&lt;br /&gt;
		$app = JFactory::getApplication(&#039;site&#039;);&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;article.id&#039;, $id);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;list.offset&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
		// Load the parameters.&lt;br /&gt;
		$params = $app-&amp;gt;getParams(&#039;com_content&#039;);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;params&#039;, $params);&lt;br /&gt;
&lt;br /&gt;
		$user = JFactory::getUser();&lt;br /&gt;
&lt;br /&gt;
		if ((!$user-&amp;gt;authorise(&#039;core.edit.state&#039;, &#039;com_content&#039;)) &amp;amp;&amp;amp; (!$user-&amp;gt;authorise(&#039;core.edit&#039;, &#039;com_content&#039;)))&lt;br /&gt;
		{&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.published&#039;, 1);&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.archived&#039;, 2);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;filter.language&#039;, JLanguageMultilang::isEnabled());&lt;br /&gt;
  		&lt;br /&gt;
 		return $model-&amp;gt;getItem($id);;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add javascript to the module ===&lt;br /&gt;
&lt;br /&gt;
If you want to use javascript for yourmodule, here is an example. It loads the javascript file in the media/mod_yourmodule/js path and adds a script to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
Read more [[J3.x:Javascript_Frameworks|J3.x:Javascript Frameworks]]&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
   $document = JFactory::getDocument();&lt;br /&gt;
   $document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this code below the line that loads the css file if you want to test it.&lt;br /&gt;
&lt;br /&gt;
* We use jQuery so we have to load it &#039;&#039;&#039;before&#039;&#039;&#039; our own modules script. Here we load the Bootstrap framework that also includes jQuery. Use JHtml::_(&#039;jquery.framework&#039;) if you only need this.&lt;br /&gt;
* We add our scriptfile &amp;quot;relative&amp;quot; to the media folder.&lt;br /&gt;
* We add the script declaration directly to the document object. It gets added to the header in the html document.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125252</id>
		<title>User:Over/Step by step to a Joomla Module - Data retrieval and styling</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125252"/>
		<updated>2014-09-08T13:56:07Z</updated>

		<summary type="html">&lt;p&gt;Over: /* mod_yourmodule.php - Load helper class */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to retrieve data from a database table in two ways, direct access to a table and using a components methods. You have to have installed the module you created in former parts of the tutorial, before you start to follow this part.&lt;br /&gt;
&lt;br /&gt;
=== Data retrieval ===&lt;br /&gt;
&lt;br /&gt;
As in the previous parts you copy a skeleton file to your module folder in your Joomla path of the server. This time you copy the helper.php file to the &amp;quot;root&amp;quot; of the module.&lt;br /&gt;
&lt;br /&gt;
==== helper.php ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
abstract class ModYourmoduleHelper&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
		//we will add some code here&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The top of the file looks like any other of our php files. Copy your own comment lines from one of the php files you have edited in the former parts of the tutorial. Then we have a class definition with a name following a convention you as well should follow. Mod + The module name + Helper. A comment block follows describing what the following function does. We will add our code within the function ( in developer language called method ). You have to read the coding standards or have a look in any Joomla! core php file to learn more about coding and commenting conventions.&lt;br /&gt;
&lt;br /&gt;
We will use an article to have a litle more dynamic data example. If you didn&#039;t create an article earlier in this tutorial series do that now. Keep it short as it&#039;s only an example. In the Module Manager you open your module and under the option tab you choose your article example. You see the title but actually the article id number is stored as parameter value.&lt;br /&gt;
&lt;br /&gt;
In the first example we&#039;ll get the article text by sending sql statements to the Joomla! database API.&lt;br /&gt;
&lt;br /&gt;
==== helper.php - The sql commands ====&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		//get the users authorisations&lt;br /&gt;
		$user       = JFactory::getUser();&lt;br /&gt;
		$groups     = implode(&#039;,&#039;, $user-&amp;gt;getAuthorisedViewLevels());&lt;br /&gt;
&lt;br /&gt;
		$db = JFactory::getDbo();&lt;br /&gt;
   		//get a db query object&lt;br /&gt;
		$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
		//select article id, title and introtext&lt;br /&gt;
		$query-&amp;gt;select(&lt;br /&gt;
			array(&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.id&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.title&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.introtext&#039;),&lt;br /&gt;
				)&lt;br /&gt;
		);&lt;br /&gt;
   		//from the article table&lt;br /&gt;
		$query-&amp;gt;from($db-&amp;gt;quoteName(&#039;#__content&#039;, &#039;a&#039;));&lt;br /&gt;
		//id from parameter, we cast to integer&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;id&#039;) . &#039; = &#039;. (int) $id);&lt;br /&gt;
		// Only return if published&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;a.state&#039;) . &#039; = 1 &#039;);&lt;br /&gt;
		//and user is authorised to read&lt;br /&gt;
		$query-&amp;gt;where(&#039;a.access IN (&#039; . $groups . &#039;)&#039;);&lt;br /&gt;
&lt;br /&gt;
		//uncomment this line to see the query string&lt;br /&gt;
		//echo $query;&lt;br /&gt;
&lt;br /&gt;
		$db-&amp;gt;setQuery($query);&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
	   		//get the article&lt;br /&gt;
			$result = $db-&amp;gt;loadObject();&lt;br /&gt;
		}&lt;br /&gt;
   		//check error&lt;br /&gt;
		catch (RuntimeException $e)&lt;br /&gt;
		{&lt;br /&gt;
			//this is a module so we skip it if there are errors&lt;br /&gt;
			// in other cases we would show a message&lt;br /&gt;
			//$app = JFactory::getApplication();&lt;br /&gt;
			//$app-&amp;gt;enqueueMessage($e-&amp;gt;getMessage(), &#039;error&#039;);&lt;br /&gt;
&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $result;&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the brief comments in the text about what we are doing here. &lt;br /&gt;
&lt;br /&gt;
Important security issue: use $db-&amp;gt;quote($field_value) to avoid so called &amp;quot;sql-injections&amp;quot; for none integer or float variables. Be very careful when you build sql queries. &lt;br /&gt;
&lt;br /&gt;
We can&#039;t describe the details to Joomla! sql queries within this tutorial. More in [http://docs.joomla.org/Accessing_the_database_using_JDatabase Accessing the database using JDatabase]&lt;br /&gt;
&lt;br /&gt;
As this is a module we don&#039;t show errormessages to the user. If there are errors the page will still be ok.&lt;br /&gt;
&lt;br /&gt;
Copy the code to your helper.php replacing the method ( = function ) getData.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The helper file is loaded and run from mod_yourmodule.php. Open it and add the following between defined(... and require.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.php - Load helper class ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    // Include the helper file that provide the data&lt;br /&gt;
   require __DIR__ . &#039;/helper.php&#039;;&lt;br /&gt;
&lt;br /&gt;
   //the class suffix from parameter&lt;br /&gt;
   $moduleclass_sfx = htmlspecialchars($params-&amp;gt;get(&#039;moduleclass_sfx&#039;));&lt;br /&gt;
 &lt;br /&gt;
  if ( !$article = ModYourmoduleHelper::getData($params))&lt;br /&gt;
   {&lt;br /&gt;
      //if error or article not found skip this module&lt;br /&gt;
      return false;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //uncomment this line to see the available fields&lt;br /&gt;
   //var_dump($article);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the same time we get the class suffix from the parameter. Explained below.&lt;br /&gt;
Now that you have the article data, we will change the output file to show it. Remember? /tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
==== default.php - Show article ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After defined(... and the php closing tab we change the html. We use embedded php code to echo the title and the introtext. We add a module specific class $moduleclass sfx to the div tag. $moduleclass sfx is the class suffix the user can add in the Module Manager -&amp;amp;gt; tab Advanced. This can be used for Css styling if multiple instances of the same module are enabled. e.g. you can test to reuse your module by choosing another article. We will style them in the next step.&lt;br /&gt;
&lt;br /&gt;
=== Css styling ===&lt;br /&gt;
Best practice on a website is to &#039;&#039;&#039;try&#039;&#039;&#039; to keep all css styling in one file. As you don&#039;t know if the users template shows your module as designed, you have to include a css file. Not really for what we have above, but in a tutorial we do as if. You should use the parameters we created in a former part, to let the user of the module exclude your css. Described in the Overrides part of the tutorial.&lt;br /&gt;
&lt;br /&gt;
We will not only prepare for loading css but also for images and javascript. Best practice is to store those files in subfolders of the Joomla media folder. Please don&#039;t ask why this folder was named media.&lt;br /&gt;
&lt;br /&gt;
Create folder path/to/your/joomla/media/mod_yourmodule. In the folder where you unpacked the tutorial zip file you&#039;ll find a media folder. Open this and copy all three subfolders to the new folder in your web folder. It should result in something like this &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/logs&lt;br /&gt;
/media&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /css                   *new directory*&lt;br /&gt;
      yourmodule.css       *new file*&lt;br /&gt;
    /images                *new directory*&lt;br /&gt;
      doc.png              *new file*&lt;br /&gt;
      yourmodule-logo.png  *new file*&lt;br /&gt;
    /js                    *new directory*&lt;br /&gt;
      yourmodule.js        *new file*&lt;br /&gt;
      yourmodule_ajax.js   *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/modules&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Did you use your module name? You don´t have to, but it´s a good practice to use distinct names.&lt;br /&gt;
&lt;br /&gt;
=== Add Css file  ===&lt;br /&gt;
&lt;br /&gt;
We include the module specific css file to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
==== default.php - Include Css file and image ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div class=&amp;quot;row text-center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;?php echo JHtml::image(&#039;mod_yourmodule/yourmodule-logo.png&#039;, &#039;Yourmodule logo&#039;, &#039;&#039;, true, false );?&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this code added yourmodule.css will be loaded from the path media/mod_yourmodule/css/&lt;br /&gt;
Be aware of the missing /css/ ! This is added by Joomla. The image will be loaded from the path media/mod_yourmodule/images/.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s test that the css is working by adding a few lines to the yourmodule.css file. Open it with the editor and add e.g. those lines that change text color. Do we have to mention the module name that was used as css class?&lt;br /&gt;
&lt;br /&gt;
==== yourmodule.css ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
.yourmodule h4{&lt;br /&gt;
	color: #08c;&lt;br /&gt;
}&lt;br /&gt;
.yourmodule p {&lt;br /&gt;
	color: #005580;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On your frontend page the colors should have changed and an image added. Have a look! Be aware that your browser may have cached the css.&lt;br /&gt;
&lt;br /&gt;
=== Update the xml and the zip file  ===&lt;br /&gt;
&lt;br /&gt;
Now we have to add the new files to the xml file and create an updated installation zip file.&lt;br /&gt;
&lt;br /&gt;
Add the helper.php and the special media tag to the xml file.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add helper.php ====&lt;br /&gt;
&lt;br /&gt;
Add helper.php to the files tag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;files&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;helper.php&amp;lt;/filename&amp;gt; &lt;br /&gt;
		&amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add media folder ====&lt;br /&gt;
&lt;br /&gt;
Add the media tag between files and languages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
	&amp;lt;media destination=&amp;quot;mod_yourmodule&amp;quot; folder=&amp;quot;media&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;css&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;images&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;js&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/media&amp;gt;&lt;br /&gt;
	&amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== Create the installation file ===&lt;br /&gt;
&lt;br /&gt;
Now you copy &#039;&#039;&#039;all&#039;&#039;&#039; module files from the server to the path &#039;somewhere&#039;/j_module_tutorial/new_module as in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
Create a new folder &#039;media&#039; and copy the three folders from media/mod_yourmodule.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  .../new_module&lt;br /&gt;
      /langs&lt;br /&gt;
        en-GB.mod_yourmodule.ini&lt;br /&gt;
        en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        anyother-language.mod_yourmodule.in&lt;br /&gt;
        anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /language&lt;br /&gt;
        /en-GB&lt;br /&gt;
          en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        /anyother-language&lt;br /&gt;
          anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /media&lt;br /&gt;
        /css&lt;br /&gt;
          yourmodule.css&lt;br /&gt;
        /images&lt;br /&gt;
          doc.png&lt;br /&gt;
          yourmodule-logo.png&lt;br /&gt;
        /js&lt;br /&gt;
          yourmodule.js&lt;br /&gt;
      /tmpl&lt;br /&gt;
        default.php&lt;br /&gt;
      mod_yourmodule.php&lt;br /&gt;
      mod_yourmodule.xml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the compressed installation zip file as described in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this tutorial. Below we describe an alternative for data retrieval.&lt;br /&gt;
&lt;br /&gt;
=== Use a component for data retrieval ===&lt;br /&gt;
&lt;br /&gt;
Below is an alternative to using direct sql. You can use the methods provided by a component to retrieve the data. If you develop your own component, you can prepare methods for reuse, otherwise you can try to find a method in a components models to retrieve the data you want. Here we reuse the getItem method of the content component ( articles ). In this case you get all article data returned. If you use a lot of modules of this type on the same page, be a little aware of momory usage. If you want to test it, you only have to replace the getData method in helper.php.&lt;br /&gt;
&lt;br /&gt;
To see the data available you can uncomment the var_dump line in mod_yourmodule.php.&lt;br /&gt;
&lt;br /&gt;
==== helper.php Use of component ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model = JModelLegacy::getInstance(&#039;Article&#039;, &#039;ContentModel&#039;, array(&#039;ignore_request&#039; =&amp;gt; true));&lt;br /&gt;
&lt;br /&gt;
		$app = JFactory::getApplication(&#039;site&#039;);&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;article.id&#039;, $id);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;list.offset&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
		// Load the parameters.&lt;br /&gt;
		$params = $app-&amp;gt;getParams(&#039;com_content&#039;);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;params&#039;, $params);&lt;br /&gt;
&lt;br /&gt;
		$user = JFactory::getUser();&lt;br /&gt;
&lt;br /&gt;
		if ((!$user-&amp;gt;authorise(&#039;core.edit.state&#039;, &#039;com_content&#039;)) &amp;amp;&amp;amp; (!$user-&amp;gt;authorise(&#039;core.edit&#039;, &#039;com_content&#039;)))&lt;br /&gt;
		{&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.published&#039;, 1);&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.archived&#039;, 2);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;filter.language&#039;, JLanguageMultilang::isEnabled());&lt;br /&gt;
  		&lt;br /&gt;
 		return $model-&amp;gt;getItem($id);;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add javascript to the module ===&lt;br /&gt;
&lt;br /&gt;
If you want to use javascript for yourmodule, here is an example. It loads the javascript file in the media/mod_yourmodule/js path and adds a script to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
Read more [[J3.x:Javascript_Frameworks|J3.x:Javascript Frameworks]]&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
   $document = JFactory::getDocument();&lt;br /&gt;
   $document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this code below the line that loads the css file if you want to test it.&lt;br /&gt;
&lt;br /&gt;
* We use jQuery so we have to load it &#039;&#039;&#039;before&#039;&#039;&#039; our own modules script. Here we load the Bootstrap framework that also includes jQuery. Use JHtml::_(&#039;jquery.framework&#039;) if you only need this.&lt;br /&gt;
* We add our scriptfile &amp;quot;relative&amp;quot; to the media folder.&lt;br /&gt;
* We add the script declaration directly to the document object. It gets added to the header in the html document.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125251</id>
		<title>User:Over/Step by step to a Joomla Module - Data retrieval and styling</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125251"/>
		<updated>2014-09-08T13:52:42Z</updated>

		<summary type="html">&lt;p&gt;Over: /* helper.php - The sql commands */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to retrieve data from a database table in two ways, direct access to a table and using a components methods. You have to have installed the module you created in former parts of the tutorial, before you start to follow this part.&lt;br /&gt;
&lt;br /&gt;
=== Data retrieval ===&lt;br /&gt;
&lt;br /&gt;
As in the previous parts you copy a skeleton file to your module folder in your Joomla path of the server. This time you copy the helper.php file to the &amp;quot;root&amp;quot; of the module.&lt;br /&gt;
&lt;br /&gt;
==== helper.php ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
abstract class ModYourmoduleHelper&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
		//we will add some code here&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The top of the file looks like any other of our php files. Copy your own comment lines from one of the php files you have edited in the former parts of the tutorial. Then we have a class definition with a name following a convention you as well should follow. Mod + The module name + Helper. A comment block follows describing what the following function does. We will add our code within the function ( in developer language called method ). You have to read the coding standards or have a look in any Joomla! core php file to learn more about coding and commenting conventions.&lt;br /&gt;
&lt;br /&gt;
We will use an article to have a litle more dynamic data example. If you didn&#039;t create an article earlier in this tutorial series do that now. Keep it short as it&#039;s only an example. In the Module Manager you open your module and under the option tab you choose your article example. You see the title but actually the article id number is stored as parameter value.&lt;br /&gt;
&lt;br /&gt;
In the first example we&#039;ll get the article text by sending sql statements to the Joomla! database API.&lt;br /&gt;
&lt;br /&gt;
==== helper.php - The sql commands ====&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		//get the users authorisations&lt;br /&gt;
		$user       = JFactory::getUser();&lt;br /&gt;
		$groups     = implode(&#039;,&#039;, $user-&amp;gt;getAuthorisedViewLevels());&lt;br /&gt;
&lt;br /&gt;
		$db = JFactory::getDbo();&lt;br /&gt;
   		//get a db query object&lt;br /&gt;
		$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
		//select article id, title and introtext&lt;br /&gt;
		$query-&amp;gt;select(&lt;br /&gt;
			array(&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.id&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.title&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.introtext&#039;),&lt;br /&gt;
				)&lt;br /&gt;
		);&lt;br /&gt;
   		//from the article table&lt;br /&gt;
		$query-&amp;gt;from($db-&amp;gt;quoteName(&#039;#__content&#039;, &#039;a&#039;));&lt;br /&gt;
		//id from parameter, we cast to integer&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;id&#039;) . &#039; = &#039;. (int) $id);&lt;br /&gt;
		// Only return if published&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;a.state&#039;) . &#039; = 1 &#039;);&lt;br /&gt;
		//and user is authorised to read&lt;br /&gt;
		$query-&amp;gt;where(&#039;a.access IN (&#039; . $groups . &#039;)&#039;);&lt;br /&gt;
&lt;br /&gt;
		//uncomment this line to see the query string&lt;br /&gt;
		//echo $query;&lt;br /&gt;
&lt;br /&gt;
		$db-&amp;gt;setQuery($query);&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
	   		//get the article&lt;br /&gt;
			$result = $db-&amp;gt;loadObject();&lt;br /&gt;
		}&lt;br /&gt;
   		//check error&lt;br /&gt;
		catch (RuntimeException $e)&lt;br /&gt;
		{&lt;br /&gt;
			//this is a module so we skip it if there are errors&lt;br /&gt;
			// in other cases we would show a message&lt;br /&gt;
			//$app = JFactory::getApplication();&lt;br /&gt;
			//$app-&amp;gt;enqueueMessage($e-&amp;gt;getMessage(), &#039;error&#039;);&lt;br /&gt;
&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $result;&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the brief comments in the text about what we are doing here. &lt;br /&gt;
&lt;br /&gt;
Important security issue: use $db-&amp;gt;quote($field_value) to avoid so called &amp;quot;sql-injections&amp;quot; for none integer or float variables. Be very careful when you build sql queries. &lt;br /&gt;
&lt;br /&gt;
We can&#039;t describe the details to Joomla! sql queries within this tutorial. More in [http://docs.joomla.org/Accessing_the_database_using_JDatabase Accessing the database using JDatabase]&lt;br /&gt;
&lt;br /&gt;
As this is a module we don&#039;t show errormessages to the user. If there are errors the page will still be ok.&lt;br /&gt;
&lt;br /&gt;
Copy the code to your helper.php replacing the method ( = function ) getData.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The helper file is loaded and run from mod_yourmodule.php. Open it and add the following between defined(... and require.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.php - Load helper class ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    // Include the helper file that provide the data&lt;br /&gt;
   require_once __DIR__ . &#039;/helper.php&#039;;&lt;br /&gt;
&lt;br /&gt;
   //the class suffix from parameter&lt;br /&gt;
   $moduleclass_sfx = htmlspecialchars($params-&amp;gt;get(&#039;moduleclass_sfx&#039;));&lt;br /&gt;
 &lt;br /&gt;
  if ( !$article = ModYourmoduleHelper::getData($params))&lt;br /&gt;
   {&lt;br /&gt;
      //if error or article not found skip this module&lt;br /&gt;
      return false;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //uncomment this line to see the available fields&lt;br /&gt;
   //var_dump($article);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the same time we get the class suffix from the parameter. Explained below.&lt;br /&gt;
Now that you have the article data, we will change the output file to show it. Remember? /tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
==== default.php - Show article ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After defined(... and the php closing tab we change the html. We use embedded php code to echo the title and the introtext. We add a module specific class $moduleclass sfx to the div tag. $moduleclass sfx is the class suffix the user can add in the Module Manager -&amp;amp;gt; tab Advanced. This can be used for Css styling if multiple instances of the same module are enabled. e.g. you can test to reuse your module by choosing another article. We will style them in the next step.&lt;br /&gt;
&lt;br /&gt;
=== Css styling ===&lt;br /&gt;
Best practice on a website is to &#039;&#039;&#039;try&#039;&#039;&#039; to keep all css styling in one file. As you don&#039;t know if the users template shows your module as designed, you have to include a css file. Not really for what we have above, but in a tutorial we do as if. You should use the parameters we created in a former part, to let the user of the module exclude your css. Described in the Overrides part of the tutorial.&lt;br /&gt;
&lt;br /&gt;
We will not only prepare for loading css but also for images and javascript. Best practice is to store those files in subfolders of the Joomla media folder. Please don&#039;t ask why this folder was named media.&lt;br /&gt;
&lt;br /&gt;
Create folder path/to/your/joomla/media/mod_yourmodule. In the folder where you unpacked the tutorial zip file you&#039;ll find a media folder. Open this and copy all three subfolders to the new folder in your web folder. It should result in something like this &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/logs&lt;br /&gt;
/media&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /css                   *new directory*&lt;br /&gt;
      yourmodule.css       *new file*&lt;br /&gt;
    /images                *new directory*&lt;br /&gt;
      doc.png              *new file*&lt;br /&gt;
      yourmodule-logo.png  *new file*&lt;br /&gt;
    /js                    *new directory*&lt;br /&gt;
      yourmodule.js        *new file*&lt;br /&gt;
      yourmodule_ajax.js   *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/modules&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Did you use your module name? You don´t have to, but it´s a good practice to use distinct names.&lt;br /&gt;
&lt;br /&gt;
=== Add Css file  ===&lt;br /&gt;
&lt;br /&gt;
We include the module specific css file to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
==== default.php - Include Css file and image ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div class=&amp;quot;row text-center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;?php echo JHtml::image(&#039;mod_yourmodule/yourmodule-logo.png&#039;, &#039;Yourmodule logo&#039;, &#039;&#039;, true, false );?&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this code added yourmodule.css will be loaded from the path media/mod_yourmodule/css/&lt;br /&gt;
Be aware of the missing /css/ ! This is added by Joomla. The image will be loaded from the path media/mod_yourmodule/images/.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s test that the css is working by adding a few lines to the yourmodule.css file. Open it with the editor and add e.g. those lines that change text color. Do we have to mention the module name that was used as css class?&lt;br /&gt;
&lt;br /&gt;
==== yourmodule.css ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
.yourmodule h4{&lt;br /&gt;
	color: #08c;&lt;br /&gt;
}&lt;br /&gt;
.yourmodule p {&lt;br /&gt;
	color: #005580;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On your frontend page the colors should have changed and an image added. Have a look! Be aware that your browser may have cached the css.&lt;br /&gt;
&lt;br /&gt;
=== Update the xml and the zip file  ===&lt;br /&gt;
&lt;br /&gt;
Now we have to add the new files to the xml file and create an updated installation zip file.&lt;br /&gt;
&lt;br /&gt;
Add the helper.php and the special media tag to the xml file.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add helper.php ====&lt;br /&gt;
&lt;br /&gt;
Add helper.php to the files tag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;files&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;helper.php&amp;lt;/filename&amp;gt; &lt;br /&gt;
		&amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add media folder ====&lt;br /&gt;
&lt;br /&gt;
Add the media tag between files and languages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
	&amp;lt;media destination=&amp;quot;mod_yourmodule&amp;quot; folder=&amp;quot;media&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;css&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;images&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;js&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/media&amp;gt;&lt;br /&gt;
	&amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== Create the installation file ===&lt;br /&gt;
&lt;br /&gt;
Now you copy &#039;&#039;&#039;all&#039;&#039;&#039; module files from the server to the path &#039;somewhere&#039;/j_module_tutorial/new_module as in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
Create a new folder &#039;media&#039; and copy the three folders from media/mod_yourmodule.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  .../new_module&lt;br /&gt;
      /langs&lt;br /&gt;
        en-GB.mod_yourmodule.ini&lt;br /&gt;
        en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        anyother-language.mod_yourmodule.in&lt;br /&gt;
        anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /language&lt;br /&gt;
        /en-GB&lt;br /&gt;
          en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        /anyother-language&lt;br /&gt;
          anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /media&lt;br /&gt;
        /css&lt;br /&gt;
          yourmodule.css&lt;br /&gt;
        /images&lt;br /&gt;
          doc.png&lt;br /&gt;
          yourmodule-logo.png&lt;br /&gt;
        /js&lt;br /&gt;
          yourmodule.js&lt;br /&gt;
      /tmpl&lt;br /&gt;
        default.php&lt;br /&gt;
      mod_yourmodule.php&lt;br /&gt;
      mod_yourmodule.xml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the compressed installation zip file as described in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this tutorial. Below we describe an alternative for data retrieval.&lt;br /&gt;
&lt;br /&gt;
=== Use a component for data retrieval ===&lt;br /&gt;
&lt;br /&gt;
Below is an alternative to using direct sql. You can use the methods provided by a component to retrieve the data. If you develop your own component, you can prepare methods for reuse, otherwise you can try to find a method in a components models to retrieve the data you want. Here we reuse the getItem method of the content component ( articles ). In this case you get all article data returned. If you use a lot of modules of this type on the same page, be a little aware of momory usage. If you want to test it, you only have to replace the getData method in helper.php.&lt;br /&gt;
&lt;br /&gt;
To see the data available you can uncomment the var_dump line in mod_yourmodule.php.&lt;br /&gt;
&lt;br /&gt;
==== helper.php Use of component ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model = JModelLegacy::getInstance(&#039;Article&#039;, &#039;ContentModel&#039;, array(&#039;ignore_request&#039; =&amp;gt; true));&lt;br /&gt;
&lt;br /&gt;
		$app = JFactory::getApplication(&#039;site&#039;);&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;article.id&#039;, $id);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;list.offset&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
		// Load the parameters.&lt;br /&gt;
		$params = $app-&amp;gt;getParams(&#039;com_content&#039;);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;params&#039;, $params);&lt;br /&gt;
&lt;br /&gt;
		$user = JFactory::getUser();&lt;br /&gt;
&lt;br /&gt;
		if ((!$user-&amp;gt;authorise(&#039;core.edit.state&#039;, &#039;com_content&#039;)) &amp;amp;&amp;amp; (!$user-&amp;gt;authorise(&#039;core.edit&#039;, &#039;com_content&#039;)))&lt;br /&gt;
		{&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.published&#039;, 1);&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.archived&#039;, 2);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;filter.language&#039;, JLanguageMultilang::isEnabled());&lt;br /&gt;
  		&lt;br /&gt;
 		return $model-&amp;gt;getItem($id);;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add javascript to the module ===&lt;br /&gt;
&lt;br /&gt;
If you want to use javascript for yourmodule, here is an example. It loads the javascript file in the media/mod_yourmodule/js path and adds a script to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
Read more [[J3.x:Javascript_Frameworks|J3.x:Javascript Frameworks]]&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
   $document = JFactory::getDocument();&lt;br /&gt;
   $document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this code below the line that loads the css file if you want to test it.&lt;br /&gt;
&lt;br /&gt;
* We use jQuery so we have to load it &#039;&#039;&#039;before&#039;&#039;&#039; our own modules script. Here we load the Bootstrap framework that also includes jQuery. Use JHtml::_(&#039;jquery.framework&#039;) if you only need this.&lt;br /&gt;
* We add our scriptfile &amp;quot;relative&amp;quot; to the media folder.&lt;br /&gt;
* We add the script declaration directly to the document object. It gets added to the header in the html document.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125248</id>
		<title>User:Over/Step by step to a Joomla Module - Data retrieval and styling</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125248"/>
		<updated>2014-09-07T08:51:00Z</updated>

		<summary type="html">&lt;p&gt;Over: /* default.php - Include Css file and image */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to retrieve data from a database table in two ways, direct access to a table and using a components methods. You have to have installed the module you created in former parts of the tutorial, before you start to follow this part.&lt;br /&gt;
&lt;br /&gt;
=== Data retrieval ===&lt;br /&gt;
&lt;br /&gt;
As in the previous parts you copy a skeleton file to your module folder in your Joomla path of the server. This time you copy the helper.php file to the &amp;quot;root&amp;quot; of the module.&lt;br /&gt;
&lt;br /&gt;
==== helper.php ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
abstract class ModYourmoduleHelper&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
		//we will add some code here&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The top of the file looks like any other of our php files. Copy your own comment lines from one of the php files you have edited in the former parts of the tutorial. Then we have a class definition with a name following a convention you as well should follow. Mod + The module name + Helper. A comment block follows describing what the following function does. We will add our code within the function ( in developer language called method ). You have to read the coding standards or have a look in any Joomla! core php file to learn more about coding and commenting conventions.&lt;br /&gt;
&lt;br /&gt;
We will use an article to have a litle more dynamic data example. If you didn&#039;t create an article earlier in this tutorial series do that now. Keep it short as it&#039;s only an example. In the Module Manager you open your module and under the option tab you choose your article example. You see the title but actually the article id number is stored as parameter value.&lt;br /&gt;
&lt;br /&gt;
In the first example we&#039;ll get the article text by sending sql statements to the Joomla! database API.&lt;br /&gt;
&lt;br /&gt;
==== helper.php - The sql commands ====&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		//get the users authorisations&lt;br /&gt;
		$user       = JFactory::getUser();&lt;br /&gt;
		$groups     = implode(&#039;,&#039;, $user-&amp;gt;getAuthorisedViewLevels());&lt;br /&gt;
&lt;br /&gt;
		$db = JFactory::getDbo();&lt;br /&gt;
   		//get a db query object&lt;br /&gt;
		$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
		//select article id, title and introtext&lt;br /&gt;
		$query-&amp;gt;select(&lt;br /&gt;
			array(&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.id&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.title&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.introtext&#039;),&lt;br /&gt;
				)&lt;br /&gt;
		);&lt;br /&gt;
   		//from the article table&lt;br /&gt;
		$query-&amp;gt;from($db-&amp;gt;quoteName(&#039;#__content&#039;, &#039;a&#039;));&lt;br /&gt;
		//id from parameter, we are conservative enough to cast the id&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;id&#039;) . &#039; = &#039;. $db-&amp;gt;quote( (int) $id));&lt;br /&gt;
		// Only return if published&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;a.state&#039;) . &#039; = 1 &#039;);&lt;br /&gt;
		//and user is authorised to read&lt;br /&gt;
		$query-&amp;gt;where(&#039;a.access IN (&#039; . $groups . &#039;)&#039;);&lt;br /&gt;
&lt;br /&gt;
		//uncomment this line to see the query string&lt;br /&gt;
		//echo $query;&lt;br /&gt;
&lt;br /&gt;
		$db-&amp;gt;setQuery($query);&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
	   		//get the article&lt;br /&gt;
			$result = $db-&amp;gt;loadObject();&lt;br /&gt;
		}&lt;br /&gt;
   		//check error&lt;br /&gt;
		catch (RuntimeException $e)&lt;br /&gt;
		{&lt;br /&gt;
			//this is a module so we skip it if there are errors&lt;br /&gt;
			// in other cases we would show a message&lt;br /&gt;
			//$app = JFactory::getApplication();&lt;br /&gt;
			//$app-&amp;gt;enqueueMessage($e-&amp;gt;getMessage(), &#039;error&#039;);&lt;br /&gt;
&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $result;&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the brief comments in the text about what we are doing here. Important security issue: use $db-&amp;amp;gt;quote(&#039;field_value&#039;) to avoid so called &amp;quot;sql-injections&amp;quot;. Be very careful when you build sql queries. We can&#039;t describe the details to Joomla! sql queries within this tutorial. More in [http://docs.joomla.org/Accessing_the_database_using_JDatabase Accessing the database using JDatabase]&lt;br /&gt;
&lt;br /&gt;
As this is a module we don&#039;t show errormessages to the user. If there are errors the page will still be ok.&lt;br /&gt;
&lt;br /&gt;
Copy the code to your helper.php replacing the method ( = function ) getData.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The helper file is loaded and run from mod_yourmodule.php. Open it and add the following between defined(... and require.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.php - Load helper class ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    // Include the helper file that provide the data&lt;br /&gt;
   require_once __DIR__ . &#039;/helper.php&#039;;&lt;br /&gt;
&lt;br /&gt;
   //the class suffix from parameter&lt;br /&gt;
   $moduleclass_sfx = htmlspecialchars($params-&amp;gt;get(&#039;moduleclass_sfx&#039;));&lt;br /&gt;
 &lt;br /&gt;
  if ( !$article = ModYourmoduleHelper::getData($params))&lt;br /&gt;
   {&lt;br /&gt;
      //if error or article not found skip this module&lt;br /&gt;
      return false;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //uncomment this line to see the available fields&lt;br /&gt;
   //var_dump($article);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the same time we get the class suffix from the parameter. Explained below.&lt;br /&gt;
Now that you have the article data, we will change the output file to show it. Remember? /tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
==== default.php - Show article ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After defined(... and the php closing tab we change the html. We use embedded php code to echo the title and the introtext. We add a module specific class $moduleclass sfx to the div tag. $moduleclass sfx is the class suffix the user can add in the Module Manager -&amp;amp;gt; tab Advanced. This can be used for Css styling if multiple instances of the same module are enabled. e.g. you can test to reuse your module by choosing another article. We will style them in the next step.&lt;br /&gt;
&lt;br /&gt;
=== Css styling ===&lt;br /&gt;
Best practice on a website is to &#039;&#039;&#039;try&#039;&#039;&#039; to keep all css styling in one file. As you don&#039;t know if the users template shows your module as designed, you have to include a css file. Not really for what we have above, but in a tutorial we do as if. You should use the parameters we created in a former part, to let the user of the module exclude your css. Described in the Overrides part of the tutorial.&lt;br /&gt;
&lt;br /&gt;
We will not only prepare for loading css but also for images and javascript. Best practice is to store those files in subfolders of the Joomla media folder. Please don&#039;t ask why this folder was named media.&lt;br /&gt;
&lt;br /&gt;
Create folder path/to/your/joomla/media/mod_yourmodule. In the folder where you unpacked the tutorial zip file you&#039;ll find a media folder. Open this and copy all three subfolders to the new folder in your web folder. It should result in something like this &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/logs&lt;br /&gt;
/media&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /css                   *new directory*&lt;br /&gt;
      yourmodule.css       *new file*&lt;br /&gt;
    /images                *new directory*&lt;br /&gt;
      doc.png              *new file*&lt;br /&gt;
      yourmodule-logo.png  *new file*&lt;br /&gt;
    /js                    *new directory*&lt;br /&gt;
      yourmodule.js        *new file*&lt;br /&gt;
      yourmodule_ajax.js   *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/modules&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Did you use your module name? You don´t have to, but it´s a good practice to use distinct names.&lt;br /&gt;
&lt;br /&gt;
=== Add Css file  ===&lt;br /&gt;
&lt;br /&gt;
We include the module specific css file to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
==== default.php - Include Css file and image ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div class=&amp;quot;row text-center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;?php echo JHtml::image(&#039;mod_yourmodule/yourmodule-logo.png&#039;, &#039;Yourmodule logo&#039;, &#039;&#039;, true, false );?&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this code added yourmodule.css will be loaded from the path media/mod_yourmodule/css/&lt;br /&gt;
Be aware of the missing /css/ ! This is added by Joomla. The image will be loaded from the path media/mod_yourmodule/images/.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s test that the css is working by adding a few lines to the yourmodule.css file. Open it with the editor and add e.g. those lines that change text color. Do we have to mention the module name that was used as css class?&lt;br /&gt;
&lt;br /&gt;
==== yourmodule.css ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
.yourmodule h4{&lt;br /&gt;
	color: #08c;&lt;br /&gt;
}&lt;br /&gt;
.yourmodule p {&lt;br /&gt;
	color: #005580;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On your frontend page the colors should have changed and an image added. Have a look! Be aware that your browser may have cached the css.&lt;br /&gt;
&lt;br /&gt;
=== Update the xml and the zip file  ===&lt;br /&gt;
&lt;br /&gt;
Now we have to add the new files to the xml file and create an updated installation zip file.&lt;br /&gt;
&lt;br /&gt;
Add the helper.php and the special media tag to the xml file.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add helper.php ====&lt;br /&gt;
&lt;br /&gt;
Add helper.php to the files tag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;files&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;helper.php&amp;lt;/filename&amp;gt; &lt;br /&gt;
		&amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add media folder ====&lt;br /&gt;
&lt;br /&gt;
Add the media tag between files and languages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
	&amp;lt;media destination=&amp;quot;mod_yourmodule&amp;quot; folder=&amp;quot;media&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;css&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;images&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;js&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/media&amp;gt;&lt;br /&gt;
	&amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== Create the installation file ===&lt;br /&gt;
&lt;br /&gt;
Now you copy &#039;&#039;&#039;all&#039;&#039;&#039; module files from the server to the path &#039;somewhere&#039;/j_module_tutorial/new_module as in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
Create a new folder &#039;media&#039; and copy the three folders from media/mod_yourmodule.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  .../new_module&lt;br /&gt;
      /langs&lt;br /&gt;
        en-GB.mod_yourmodule.ini&lt;br /&gt;
        en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        anyother-language.mod_yourmodule.in&lt;br /&gt;
        anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /language&lt;br /&gt;
        /en-GB&lt;br /&gt;
          en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        /anyother-language&lt;br /&gt;
          anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /media&lt;br /&gt;
        /css&lt;br /&gt;
          yourmodule.css&lt;br /&gt;
        /images&lt;br /&gt;
          doc.png&lt;br /&gt;
          yourmodule-logo.png&lt;br /&gt;
        /js&lt;br /&gt;
          yourmodule.js&lt;br /&gt;
      /tmpl&lt;br /&gt;
        default.php&lt;br /&gt;
      mod_yourmodule.php&lt;br /&gt;
      mod_yourmodule.xml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the compressed installation zip file as described in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this tutorial. Below we describe an alternative for data retrieval.&lt;br /&gt;
&lt;br /&gt;
=== Use a component for data retrieval ===&lt;br /&gt;
&lt;br /&gt;
Below is an alternative to using direct sql. You can use the methods provided by a component to retrieve the data. If you develop your own component, you can prepare methods for reuse, otherwise you can try to find a method in a components models to retrieve the data you want. Here we reuse the getItem method of the content component ( articles ). In this case you get all article data returned. If you use a lot of modules of this type on the same page, be a little aware of momory usage. If you want to test it, you only have to replace the getData method in helper.php.&lt;br /&gt;
&lt;br /&gt;
To see the data available you can uncomment the var_dump line in mod_yourmodule.php.&lt;br /&gt;
&lt;br /&gt;
==== helper.php Use of component ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model = JModelLegacy::getInstance(&#039;Article&#039;, &#039;ContentModel&#039;, array(&#039;ignore_request&#039; =&amp;gt; true));&lt;br /&gt;
&lt;br /&gt;
		$app = JFactory::getApplication(&#039;site&#039;);&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;article.id&#039;, $id);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;list.offset&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
		// Load the parameters.&lt;br /&gt;
		$params = $app-&amp;gt;getParams(&#039;com_content&#039;);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;params&#039;, $params);&lt;br /&gt;
&lt;br /&gt;
		$user = JFactory::getUser();&lt;br /&gt;
&lt;br /&gt;
		if ((!$user-&amp;gt;authorise(&#039;core.edit.state&#039;, &#039;com_content&#039;)) &amp;amp;&amp;amp; (!$user-&amp;gt;authorise(&#039;core.edit&#039;, &#039;com_content&#039;)))&lt;br /&gt;
		{&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.published&#039;, 1);&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.archived&#039;, 2);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;filter.language&#039;, JLanguageMultilang::isEnabled());&lt;br /&gt;
  		&lt;br /&gt;
 		return $model-&amp;gt;getItem($id);;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add javascript to the module ===&lt;br /&gt;
&lt;br /&gt;
If you want to use javascript for yourmodule, here is an example. It loads the javascript file in the media/mod_yourmodule/js path and adds a script to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
Read more [[J3.x:Javascript_Frameworks|J3.x:Javascript Frameworks]]&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
   $document = JFactory::getDocument();&lt;br /&gt;
   $document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this code below the line that loads the css file if you want to test it.&lt;br /&gt;
&lt;br /&gt;
* We use jQuery so we have to load it &#039;&#039;&#039;before&#039;&#039;&#039; our own modules script. Here we load the Bootstrap framework that also includes jQuery. Use JHtml::_(&#039;jquery.framework&#039;) if you only need this.&lt;br /&gt;
* We add our scriptfile &amp;quot;relative&amp;quot; to the media folder.&lt;br /&gt;
* We add the script declaration directly to the document object. It gets added to the header in the html document.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125247</id>
		<title>User:Over/Step by step to a Joomla Module - Data retrieval and styling</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125247"/>
		<updated>2014-09-07T08:49:42Z</updated>

		<summary type="html">&lt;p&gt;Over: /* default.php - Include Css file and image */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to retrieve data from a database table in two ways, direct access to a table and using a components methods. You have to have installed the module you created in former parts of the tutorial, before you start to follow this part.&lt;br /&gt;
&lt;br /&gt;
=== Data retrieval ===&lt;br /&gt;
&lt;br /&gt;
As in the previous parts you copy a skeleton file to your module folder in your Joomla path of the server. This time you copy the helper.php file to the &amp;quot;root&amp;quot; of the module.&lt;br /&gt;
&lt;br /&gt;
==== helper.php ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
abstract class ModYourmoduleHelper&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
		//we will add some code here&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The top of the file looks like any other of our php files. Copy your own comment lines from one of the php files you have edited in the former parts of the tutorial. Then we have a class definition with a name following a convention you as well should follow. Mod + The module name + Helper. A comment block follows describing what the following function does. We will add our code within the function ( in developer language called method ). You have to read the coding standards or have a look in any Joomla! core php file to learn more about coding and commenting conventions.&lt;br /&gt;
&lt;br /&gt;
We will use an article to have a litle more dynamic data example. If you didn&#039;t create an article earlier in this tutorial series do that now. Keep it short as it&#039;s only an example. In the Module Manager you open your module and under the option tab you choose your article example. You see the title but actually the article id number is stored as parameter value.&lt;br /&gt;
&lt;br /&gt;
In the first example we&#039;ll get the article text by sending sql statements to the Joomla! database API.&lt;br /&gt;
&lt;br /&gt;
==== helper.php - The sql commands ====&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		//get the users authorisations&lt;br /&gt;
		$user       = JFactory::getUser();&lt;br /&gt;
		$groups     = implode(&#039;,&#039;, $user-&amp;gt;getAuthorisedViewLevels());&lt;br /&gt;
&lt;br /&gt;
		$db = JFactory::getDbo();&lt;br /&gt;
   		//get a db query object&lt;br /&gt;
		$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
		//select article id, title and introtext&lt;br /&gt;
		$query-&amp;gt;select(&lt;br /&gt;
			array(&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.id&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.title&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.introtext&#039;),&lt;br /&gt;
				)&lt;br /&gt;
		);&lt;br /&gt;
   		//from the article table&lt;br /&gt;
		$query-&amp;gt;from($db-&amp;gt;quoteName(&#039;#__content&#039;, &#039;a&#039;));&lt;br /&gt;
		//id from parameter, we are conservative enough to cast the id&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;id&#039;) . &#039; = &#039;. $db-&amp;gt;quote( (int) $id));&lt;br /&gt;
		// Only return if published&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;a.state&#039;) . &#039; = 1 &#039;);&lt;br /&gt;
		//and user is authorised to read&lt;br /&gt;
		$query-&amp;gt;where(&#039;a.access IN (&#039; . $groups . &#039;)&#039;);&lt;br /&gt;
&lt;br /&gt;
		//uncomment this line to see the query string&lt;br /&gt;
		//echo $query;&lt;br /&gt;
&lt;br /&gt;
		$db-&amp;gt;setQuery($query);&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
	   		//get the article&lt;br /&gt;
			$result = $db-&amp;gt;loadObject();&lt;br /&gt;
		}&lt;br /&gt;
   		//check error&lt;br /&gt;
		catch (RuntimeException $e)&lt;br /&gt;
		{&lt;br /&gt;
			//this is a module so we skip it if there are errors&lt;br /&gt;
			// in other cases we would show a message&lt;br /&gt;
			//$app = JFactory::getApplication();&lt;br /&gt;
			//$app-&amp;gt;enqueueMessage($e-&amp;gt;getMessage(), &#039;error&#039;);&lt;br /&gt;
&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $result;&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the brief comments in the text about what we are doing here. Important security issue: use $db-&amp;amp;gt;quote(&#039;field_value&#039;) to avoid so called &amp;quot;sql-injections&amp;quot;. Be very careful when you build sql queries. We can&#039;t describe the details to Joomla! sql queries within this tutorial. More in [http://docs.joomla.org/Accessing_the_database_using_JDatabase Accessing the database using JDatabase]&lt;br /&gt;
&lt;br /&gt;
As this is a module we don&#039;t show errormessages to the user. If there are errors the page will still be ok.&lt;br /&gt;
&lt;br /&gt;
Copy the code to your helper.php replacing the method ( = function ) getData.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The helper file is loaded and run from mod_yourmodule.php. Open it and add the following between defined(... and require.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.php - Load helper class ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    // Include the helper file that provide the data&lt;br /&gt;
   require_once __DIR__ . &#039;/helper.php&#039;;&lt;br /&gt;
&lt;br /&gt;
   //the class suffix from parameter&lt;br /&gt;
   $moduleclass_sfx = htmlspecialchars($params-&amp;gt;get(&#039;moduleclass_sfx&#039;));&lt;br /&gt;
 &lt;br /&gt;
  if ( !$article = ModYourmoduleHelper::getData($params))&lt;br /&gt;
   {&lt;br /&gt;
      //if error or article not found skip this module&lt;br /&gt;
      return false;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //uncomment this line to see the available fields&lt;br /&gt;
   //var_dump($article);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the same time we get the class suffix from the parameter. Explained below.&lt;br /&gt;
Now that you have the article data, we will change the output file to show it. Remember? /tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
==== default.php - Show article ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After defined(... and the php closing tab we change the html. We use embedded php code to echo the title and the introtext. We add a module specific class $moduleclass sfx to the div tag. $moduleclass sfx is the class suffix the user can add in the Module Manager -&amp;amp;gt; tab Advanced. This can be used for Css styling if multiple instances of the same module are enabled. e.g. you can test to reuse your module by choosing another article. We will style them in the next step.&lt;br /&gt;
&lt;br /&gt;
=== Css styling ===&lt;br /&gt;
Best practice on a website is to &#039;&#039;&#039;try&#039;&#039;&#039; to keep all css styling in one file. As you don&#039;t know if the users template shows your module as designed, you have to include a css file. Not really for what we have above, but in a tutorial we do as if. You should use the parameters we created in a former part, to let the user of the module exclude your css. Described in the Overrides part of the tutorial.&lt;br /&gt;
&lt;br /&gt;
We will not only prepare for loading css but also for images and javascript. Best practice is to store those files in subfolders of the Joomla media folder. Please don&#039;t ask why this folder was named media.&lt;br /&gt;
&lt;br /&gt;
Create folder path/to/your/joomla/media/mod_yourmodule. In the folder where you unpacked the tutorial zip file you&#039;ll find a media folder. Open this and copy all three subfolders to the new folder in your web folder. It should result in something like this &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/logs&lt;br /&gt;
/media&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /css                   *new directory*&lt;br /&gt;
      yourmodule.css       *new file*&lt;br /&gt;
    /images                *new directory*&lt;br /&gt;
      doc.png              *new file*&lt;br /&gt;
      yourmodule-logo.png  *new file*&lt;br /&gt;
    /js                    *new directory*&lt;br /&gt;
      yourmodule.js        *new file*&lt;br /&gt;
      yourmodule_ajax.js   *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/modules&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Did you use your module name? You don´t have to, but it´s a good practice to use distinct names.&lt;br /&gt;
&lt;br /&gt;
=== Add Css file  ===&lt;br /&gt;
&lt;br /&gt;
We include the module specific css file to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
==== default.php - Include Css file and image ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div class=&amp;quot;row text-center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;?php echo JHtml::image(&#039;mod_yourmodule/yourmodule-logo.png&#039;, &#039;Yourmodule logo&#039;, &#039;&#039;, true, false );?&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this code added yourmodule.css will be loaded from the path media/mod_yourmodule/css/&lt;br /&gt;
Be aware of the missing /css/ ! This is added by Joomla. The image will be loaded from the path media/mod_yourmodule/images/.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s test that the css is working by adding a few lines to the yourmodule.css file. Open it with the editor and add e.g. those lines that change text color. Do we have to mention the module name that was as css class?&lt;br /&gt;
&lt;br /&gt;
==== yourmodule.css ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
.yourmodule h4{&lt;br /&gt;
	color: #08c;&lt;br /&gt;
}&lt;br /&gt;
.yourmodule p {&lt;br /&gt;
	color: #005580;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On your frontend page the colors should have changed and an image added. Have a look! Be aware that your browser may have cached the css.&lt;br /&gt;
&lt;br /&gt;
=== Update the xml and the zip file  ===&lt;br /&gt;
&lt;br /&gt;
Now we have to add the new files to the xml file and create an updated installation zip file.&lt;br /&gt;
&lt;br /&gt;
Add the helper.php and the special media tag to the xml file.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add helper.php ====&lt;br /&gt;
&lt;br /&gt;
Add helper.php to the files tag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;files&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;helper.php&amp;lt;/filename&amp;gt; &lt;br /&gt;
		&amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add media folder ====&lt;br /&gt;
&lt;br /&gt;
Add the media tag between files and languages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
	&amp;lt;media destination=&amp;quot;mod_yourmodule&amp;quot; folder=&amp;quot;media&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;css&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;images&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;js&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/media&amp;gt;&lt;br /&gt;
	&amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== Create the installation file ===&lt;br /&gt;
&lt;br /&gt;
Now you copy &#039;&#039;&#039;all&#039;&#039;&#039; module files from the server to the path &#039;somewhere&#039;/j_module_tutorial/new_module as in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
Create a new folder &#039;media&#039; and copy the three folders from media/mod_yourmodule.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  .../new_module&lt;br /&gt;
      /langs&lt;br /&gt;
        en-GB.mod_yourmodule.ini&lt;br /&gt;
        en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        anyother-language.mod_yourmodule.in&lt;br /&gt;
        anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /language&lt;br /&gt;
        /en-GB&lt;br /&gt;
          en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        /anyother-language&lt;br /&gt;
          anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /media&lt;br /&gt;
        /css&lt;br /&gt;
          yourmodule.css&lt;br /&gt;
        /images&lt;br /&gt;
          doc.png&lt;br /&gt;
          yourmodule-logo.png&lt;br /&gt;
        /js&lt;br /&gt;
          yourmodule.js&lt;br /&gt;
      /tmpl&lt;br /&gt;
        default.php&lt;br /&gt;
      mod_yourmodule.php&lt;br /&gt;
      mod_yourmodule.xml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the compressed installation zip file as described in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this tutorial. Below we describe an alternative for data retrieval.&lt;br /&gt;
&lt;br /&gt;
=== Use a component for data retrieval ===&lt;br /&gt;
&lt;br /&gt;
Below is an alternative to using direct sql. You can use the methods provided by a component to retrieve the data. If you develop your own component, you can prepare methods for reuse, otherwise you can try to find a method in a components models to retrieve the data you want. Here we reuse the getItem method of the content component ( articles ). In this case you get all article data returned. If you use a lot of modules of this type on the same page, be a little aware of momory usage. If you want to test it, you only have to replace the getData method in helper.php.&lt;br /&gt;
&lt;br /&gt;
To see the data available you can uncomment the var_dump line in mod_yourmodule.php.&lt;br /&gt;
&lt;br /&gt;
==== helper.php Use of component ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model = JModelLegacy::getInstance(&#039;Article&#039;, &#039;ContentModel&#039;, array(&#039;ignore_request&#039; =&amp;gt; true));&lt;br /&gt;
&lt;br /&gt;
		$app = JFactory::getApplication(&#039;site&#039;);&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;article.id&#039;, $id);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;list.offset&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
		// Load the parameters.&lt;br /&gt;
		$params = $app-&amp;gt;getParams(&#039;com_content&#039;);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;params&#039;, $params);&lt;br /&gt;
&lt;br /&gt;
		$user = JFactory::getUser();&lt;br /&gt;
&lt;br /&gt;
		if ((!$user-&amp;gt;authorise(&#039;core.edit.state&#039;, &#039;com_content&#039;)) &amp;amp;&amp;amp; (!$user-&amp;gt;authorise(&#039;core.edit&#039;, &#039;com_content&#039;)))&lt;br /&gt;
		{&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.published&#039;, 1);&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.archived&#039;, 2);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;filter.language&#039;, JLanguageMultilang::isEnabled());&lt;br /&gt;
  		&lt;br /&gt;
 		return $model-&amp;gt;getItem($id);;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add javascript to the module ===&lt;br /&gt;
&lt;br /&gt;
If you want to use javascript for yourmodule, here is an example. It loads the javascript file in the media/mod_yourmodule/js path and adds a script to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
Read more [[J3.x:Javascript_Frameworks|J3.x:Javascript Frameworks]]&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
   $document = JFactory::getDocument();&lt;br /&gt;
   $document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this code below the line that loads the css file if you want to test it.&lt;br /&gt;
&lt;br /&gt;
* We use jQuery so we have to load it &#039;&#039;&#039;before&#039;&#039;&#039; our own modules script. Here we load the Bootstrap framework that also includes jQuery. Use JHtml::_(&#039;jquery.framework&#039;) if you only need this.&lt;br /&gt;
* We add our scriptfile &amp;quot;relative&amp;quot; to the media folder.&lt;br /&gt;
* We add the script declaration directly to the document object. It gets added to the header in the html document.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125246</id>
		<title>User:Over/Step by step to a Joomla Module - Data retrieval and styling</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125246"/>
		<updated>2014-09-07T08:46:00Z</updated>

		<summary type="html">&lt;p&gt;Over: /* default.php Javascript */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to retrieve data from a database table in two ways, direct access to a table and using a components methods. You have to have installed the module you created in former parts of the tutorial, before you start to follow this part.&lt;br /&gt;
&lt;br /&gt;
=== Data retrieval ===&lt;br /&gt;
&lt;br /&gt;
As in the previous parts you copy a skeleton file to your module folder in your Joomla path of the server. This time you copy the helper.php file to the &amp;quot;root&amp;quot; of the module.&lt;br /&gt;
&lt;br /&gt;
==== helper.php ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
abstract class ModYourmoduleHelper&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
		//we will add some code here&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The top of the file looks like any other of our php files. Copy your own comment lines from one of the php files you have edited in the former parts of the tutorial. Then we have a class definition with a name following a convention you as well should follow. Mod + The module name + Helper. A comment block follows describing what the following function does. We will add our code within the function ( in developer language called method ). You have to read the coding standards or have a look in any Joomla! core php file to learn more about coding and commenting conventions.&lt;br /&gt;
&lt;br /&gt;
We will use an article to have a litle more dynamic data example. If you didn&#039;t create an article earlier in this tutorial series do that now. Keep it short as it&#039;s only an example. In the Module Manager you open your module and under the option tab you choose your article example. You see the title but actually the article id number is stored as parameter value.&lt;br /&gt;
&lt;br /&gt;
In the first example we&#039;ll get the article text by sending sql statements to the Joomla! database API.&lt;br /&gt;
&lt;br /&gt;
==== helper.php - The sql commands ====&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		//get the users authorisations&lt;br /&gt;
		$user       = JFactory::getUser();&lt;br /&gt;
		$groups     = implode(&#039;,&#039;, $user-&amp;gt;getAuthorisedViewLevels());&lt;br /&gt;
&lt;br /&gt;
		$db = JFactory::getDbo();&lt;br /&gt;
   		//get a db query object&lt;br /&gt;
		$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
		//select article id, title and introtext&lt;br /&gt;
		$query-&amp;gt;select(&lt;br /&gt;
			array(&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.id&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.title&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.introtext&#039;),&lt;br /&gt;
				)&lt;br /&gt;
		);&lt;br /&gt;
   		//from the article table&lt;br /&gt;
		$query-&amp;gt;from($db-&amp;gt;quoteName(&#039;#__content&#039;, &#039;a&#039;));&lt;br /&gt;
		//id from parameter, we are conservative enough to cast the id&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;id&#039;) . &#039; = &#039;. $db-&amp;gt;quote( (int) $id));&lt;br /&gt;
		// Only return if published&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;a.state&#039;) . &#039; = 1 &#039;);&lt;br /&gt;
		//and user is authorised to read&lt;br /&gt;
		$query-&amp;gt;where(&#039;a.access IN (&#039; . $groups . &#039;)&#039;);&lt;br /&gt;
&lt;br /&gt;
		//uncomment this line to see the query string&lt;br /&gt;
		//echo $query;&lt;br /&gt;
&lt;br /&gt;
		$db-&amp;gt;setQuery($query);&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
	   		//get the article&lt;br /&gt;
			$result = $db-&amp;gt;loadObject();&lt;br /&gt;
		}&lt;br /&gt;
   		//check error&lt;br /&gt;
		catch (RuntimeException $e)&lt;br /&gt;
		{&lt;br /&gt;
			//this is a module so we skip it if there are errors&lt;br /&gt;
			// in other cases we would show a message&lt;br /&gt;
			//$app = JFactory::getApplication();&lt;br /&gt;
			//$app-&amp;gt;enqueueMessage($e-&amp;gt;getMessage(), &#039;error&#039;);&lt;br /&gt;
&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $result;&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the brief comments in the text about what we are doing here. Important security issue: use $db-&amp;amp;gt;quote(&#039;field_value&#039;) to avoid so called &amp;quot;sql-injections&amp;quot;. Be very careful when you build sql queries. We can&#039;t describe the details to Joomla! sql queries within this tutorial. More in [http://docs.joomla.org/Accessing_the_database_using_JDatabase Accessing the database using JDatabase]&lt;br /&gt;
&lt;br /&gt;
As this is a module we don&#039;t show errormessages to the user. If there are errors the page will still be ok.&lt;br /&gt;
&lt;br /&gt;
Copy the code to your helper.php replacing the method ( = function ) getData.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The helper file is loaded and run from mod_yourmodule.php. Open it and add the following between defined(... and require.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.php - Load helper class ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    // Include the helper file that provide the data&lt;br /&gt;
   require_once __DIR__ . &#039;/helper.php&#039;;&lt;br /&gt;
&lt;br /&gt;
   //the class suffix from parameter&lt;br /&gt;
   $moduleclass_sfx = htmlspecialchars($params-&amp;gt;get(&#039;moduleclass_sfx&#039;));&lt;br /&gt;
 &lt;br /&gt;
  if ( !$article = ModYourmoduleHelper::getData($params))&lt;br /&gt;
   {&lt;br /&gt;
      //if error or article not found skip this module&lt;br /&gt;
      return false;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //uncomment this line to see the available fields&lt;br /&gt;
   //var_dump($article);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the same time we get the class suffix from the parameter. Explained below.&lt;br /&gt;
Now that you have the article data, we will change the output file to show it. Remember? /tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
==== default.php - Show article ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After defined(... and the php closing tab we change the html. We use embedded php code to echo the title and the introtext. We add a module specific class $moduleclass sfx to the div tag. $moduleclass sfx is the class suffix the user can add in the Module Manager -&amp;amp;gt; tab Advanced. This can be used for Css styling if multiple instances of the same module are enabled. e.g. you can test to reuse your module by choosing another article. We will style them in the next step.&lt;br /&gt;
&lt;br /&gt;
=== Css styling ===&lt;br /&gt;
Best practice on a website is to &#039;&#039;&#039;try&#039;&#039;&#039; to keep all css styling in one file. As you don&#039;t know if the users template shows your module as designed, you have to include a css file. Not really for what we have above, but in a tutorial we do as if. You should use the parameters we created in a former part, to let the user of the module exclude your css. Described in the Overrides part of the tutorial.&lt;br /&gt;
&lt;br /&gt;
We will not only prepare for loading css but also for images and javascript. Best practice is to store those files in subfolders of the Joomla media folder. Please don&#039;t ask why this folder was named media.&lt;br /&gt;
&lt;br /&gt;
Create folder path/to/your/joomla/media/mod_yourmodule. In the folder where you unpacked the tutorial zip file you&#039;ll find a media folder. Open this and copy all three subfolders to the new folder in your web folder. It should result in something like this &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/logs&lt;br /&gt;
/media&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /css                   *new directory*&lt;br /&gt;
      yourmodule.css       *new file*&lt;br /&gt;
    /images                *new directory*&lt;br /&gt;
      doc.png              *new file*&lt;br /&gt;
      yourmodule-logo.png  *new file*&lt;br /&gt;
    /js                    *new directory*&lt;br /&gt;
      yourmodule.js        *new file*&lt;br /&gt;
      yourmodule_ajax.js   *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/modules&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Did you use your module name? You don´t have to, but it´s a good practice to use distinct names.&lt;br /&gt;
&lt;br /&gt;
=== Add Css file  ===&lt;br /&gt;
&lt;br /&gt;
We include the module specific css file to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
==== default.php - Include Css file and image ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div class=&amp;quot;row text-center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;?php echo JHtml::image(&#039;mod_yourmodule/yourmodule-logo.png&#039;, &#039;Yourmodule logo&#039;, &#039;&#039;, true, false );?&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this code added yourmodule.css will be loaded from the path media/mod_yourmodule/css/&lt;br /&gt;
Be aware of the missing /css/ ! This is added by Joomla. The image will be loaded from the path media/mod_yourmodule/images/.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s test that the css is working by adding a few lines to the yourmodule.css file. Open it with the editor and add e.g. those lines that change text color. Do we have to mention the module name?&lt;br /&gt;
&lt;br /&gt;
==== yourmodule.css ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
.yourmodule h4{&lt;br /&gt;
	color: #08c;&lt;br /&gt;
}&lt;br /&gt;
.yourmodule p {&lt;br /&gt;
	color: #005580;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On your frontend page the colors should have changed and an image added. Have a look! Be aware that your browser may have cached the css.&lt;br /&gt;
&lt;br /&gt;
=== Update the xml and the zip file  ===&lt;br /&gt;
&lt;br /&gt;
Now we have to add the new files to the xml file and create an updated installation zip file.&lt;br /&gt;
&lt;br /&gt;
Add the helper.php and the special media tag to the xml file.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add helper.php ====&lt;br /&gt;
&lt;br /&gt;
Add helper.php to the files tag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;files&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;helper.php&amp;lt;/filename&amp;gt; &lt;br /&gt;
		&amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add media folder ====&lt;br /&gt;
&lt;br /&gt;
Add the media tag between files and languages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
	&amp;lt;media destination=&amp;quot;mod_yourmodule&amp;quot; folder=&amp;quot;media&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;css&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;images&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;js&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/media&amp;gt;&lt;br /&gt;
	&amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== Create the installation file ===&lt;br /&gt;
&lt;br /&gt;
Now you copy &#039;&#039;&#039;all&#039;&#039;&#039; module files from the server to the path &#039;somewhere&#039;/j_module_tutorial/new_module as in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
Create a new folder &#039;media&#039; and copy the three folders from media/mod_yourmodule.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  .../new_module&lt;br /&gt;
      /langs&lt;br /&gt;
        en-GB.mod_yourmodule.ini&lt;br /&gt;
        en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        anyother-language.mod_yourmodule.in&lt;br /&gt;
        anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /language&lt;br /&gt;
        /en-GB&lt;br /&gt;
          en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        /anyother-language&lt;br /&gt;
          anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /media&lt;br /&gt;
        /css&lt;br /&gt;
          yourmodule.css&lt;br /&gt;
        /images&lt;br /&gt;
          doc.png&lt;br /&gt;
          yourmodule-logo.png&lt;br /&gt;
        /js&lt;br /&gt;
          yourmodule.js&lt;br /&gt;
      /tmpl&lt;br /&gt;
        default.php&lt;br /&gt;
      mod_yourmodule.php&lt;br /&gt;
      mod_yourmodule.xml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the compressed installation zip file as described in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this tutorial. Below we describe an alternative for data retrieval.&lt;br /&gt;
&lt;br /&gt;
=== Use a component for data retrieval ===&lt;br /&gt;
&lt;br /&gt;
Below is an alternative to using direct sql. You can use the methods provided by a component to retrieve the data. If you develop your own component, you can prepare methods for reuse, otherwise you can try to find a method in a components models to retrieve the data you want. Here we reuse the getItem method of the content component ( articles ). In this case you get all article data returned. If you use a lot of modules of this type on the same page, be a little aware of momory usage. If you want to test it, you only have to replace the getData method in helper.php.&lt;br /&gt;
&lt;br /&gt;
To see the data available you can uncomment the var_dump line in mod_yourmodule.php.&lt;br /&gt;
&lt;br /&gt;
==== helper.php Use of component ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model = JModelLegacy::getInstance(&#039;Article&#039;, &#039;ContentModel&#039;, array(&#039;ignore_request&#039; =&amp;gt; true));&lt;br /&gt;
&lt;br /&gt;
		$app = JFactory::getApplication(&#039;site&#039;);&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;article.id&#039;, $id);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;list.offset&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
		// Load the parameters.&lt;br /&gt;
		$params = $app-&amp;gt;getParams(&#039;com_content&#039;);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;params&#039;, $params);&lt;br /&gt;
&lt;br /&gt;
		$user = JFactory::getUser();&lt;br /&gt;
&lt;br /&gt;
		if ((!$user-&amp;gt;authorise(&#039;core.edit.state&#039;, &#039;com_content&#039;)) &amp;amp;&amp;amp; (!$user-&amp;gt;authorise(&#039;core.edit&#039;, &#039;com_content&#039;)))&lt;br /&gt;
		{&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.published&#039;, 1);&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.archived&#039;, 2);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;filter.language&#039;, JLanguageMultilang::isEnabled());&lt;br /&gt;
  		&lt;br /&gt;
 		return $model-&amp;gt;getItem($id);;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add javascript to the module ===&lt;br /&gt;
&lt;br /&gt;
If you want to use javascript for yourmodule, here is an example. It loads the javascript file in the media/mod_yourmodule/js path and adds a script to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
Read more [[J3.x:Javascript_Frameworks|J3.x:Javascript Frameworks]]&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
   $document = JFactory::getDocument();&lt;br /&gt;
   $document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this code below the line that loads the css file if you want to test it.&lt;br /&gt;
&lt;br /&gt;
* We use jQuery so we have to load it &#039;&#039;&#039;before&#039;&#039;&#039; our own modules script. Here we load the Bootstrap framework that also includes jQuery. Use JHtml::_(&#039;jquery.framework&#039;) if you only need this.&lt;br /&gt;
* We add our scriptfile &amp;quot;relative&amp;quot; to the media folder.&lt;br /&gt;
* We add the script declaration directly to the document object. It gets added to the header in the html document.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125245</id>
		<title>User:Over/Step by step to a Joomla Module - Data retrieval and styling</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125245"/>
		<updated>2014-09-07T08:42:32Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Use a component for data retrieval */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to retrieve data from a database table in two ways, direct access to a table and using a components methods. You have to have installed the module you created in former parts of the tutorial, before you start to follow this part.&lt;br /&gt;
&lt;br /&gt;
=== Data retrieval ===&lt;br /&gt;
&lt;br /&gt;
As in the previous parts you copy a skeleton file to your module folder in your Joomla path of the server. This time you copy the helper.php file to the &amp;quot;root&amp;quot; of the module.&lt;br /&gt;
&lt;br /&gt;
==== helper.php ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
abstract class ModYourmoduleHelper&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
		//we will add some code here&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The top of the file looks like any other of our php files. Copy your own comment lines from one of the php files you have edited in the former parts of the tutorial. Then we have a class definition with a name following a convention you as well should follow. Mod + The module name + Helper. A comment block follows describing what the following function does. We will add our code within the function ( in developer language called method ). You have to read the coding standards or have a look in any Joomla! core php file to learn more about coding and commenting conventions.&lt;br /&gt;
&lt;br /&gt;
We will use an article to have a litle more dynamic data example. If you didn&#039;t create an article earlier in this tutorial series do that now. Keep it short as it&#039;s only an example. In the Module Manager you open your module and under the option tab you choose your article example. You see the title but actually the article id number is stored as parameter value.&lt;br /&gt;
&lt;br /&gt;
In the first example we&#039;ll get the article text by sending sql statements to the Joomla! database API.&lt;br /&gt;
&lt;br /&gt;
==== helper.php - The sql commands ====&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		//get the users authorisations&lt;br /&gt;
		$user       = JFactory::getUser();&lt;br /&gt;
		$groups     = implode(&#039;,&#039;, $user-&amp;gt;getAuthorisedViewLevels());&lt;br /&gt;
&lt;br /&gt;
		$db = JFactory::getDbo();&lt;br /&gt;
   		//get a db query object&lt;br /&gt;
		$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
		//select article id, title and introtext&lt;br /&gt;
		$query-&amp;gt;select(&lt;br /&gt;
			array(&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.id&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.title&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.introtext&#039;),&lt;br /&gt;
				)&lt;br /&gt;
		);&lt;br /&gt;
   		//from the article table&lt;br /&gt;
		$query-&amp;gt;from($db-&amp;gt;quoteName(&#039;#__content&#039;, &#039;a&#039;));&lt;br /&gt;
		//id from parameter, we are conservative enough to cast the id&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;id&#039;) . &#039; = &#039;. $db-&amp;gt;quote( (int) $id));&lt;br /&gt;
		// Only return if published&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;a.state&#039;) . &#039; = 1 &#039;);&lt;br /&gt;
		//and user is authorised to read&lt;br /&gt;
		$query-&amp;gt;where(&#039;a.access IN (&#039; . $groups . &#039;)&#039;);&lt;br /&gt;
&lt;br /&gt;
		//uncomment this line to see the query string&lt;br /&gt;
		//echo $query;&lt;br /&gt;
&lt;br /&gt;
		$db-&amp;gt;setQuery($query);&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
	   		//get the article&lt;br /&gt;
			$result = $db-&amp;gt;loadObject();&lt;br /&gt;
		}&lt;br /&gt;
   		//check error&lt;br /&gt;
		catch (RuntimeException $e)&lt;br /&gt;
		{&lt;br /&gt;
			//this is a module so we skip it if there are errors&lt;br /&gt;
			// in other cases we would show a message&lt;br /&gt;
			//$app = JFactory::getApplication();&lt;br /&gt;
			//$app-&amp;gt;enqueueMessage($e-&amp;gt;getMessage(), &#039;error&#039;);&lt;br /&gt;
&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $result;&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the brief comments in the text about what we are doing here. Important security issue: use $db-&amp;amp;gt;quote(&#039;field_value&#039;) to avoid so called &amp;quot;sql-injections&amp;quot;. Be very careful when you build sql queries. We can&#039;t describe the details to Joomla! sql queries within this tutorial. More in [http://docs.joomla.org/Accessing_the_database_using_JDatabase Accessing the database using JDatabase]&lt;br /&gt;
&lt;br /&gt;
As this is a module we don&#039;t show errormessages to the user. If there are errors the page will still be ok.&lt;br /&gt;
&lt;br /&gt;
Copy the code to your helper.php replacing the method ( = function ) getData.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The helper file is loaded and run from mod_yourmodule.php. Open it and add the following between defined(... and require.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.php - Load helper class ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    // Include the helper file that provide the data&lt;br /&gt;
   require_once __DIR__ . &#039;/helper.php&#039;;&lt;br /&gt;
&lt;br /&gt;
   //the class suffix from parameter&lt;br /&gt;
   $moduleclass_sfx = htmlspecialchars($params-&amp;gt;get(&#039;moduleclass_sfx&#039;));&lt;br /&gt;
 &lt;br /&gt;
  if ( !$article = ModYourmoduleHelper::getData($params))&lt;br /&gt;
   {&lt;br /&gt;
      //if error or article not found skip this module&lt;br /&gt;
      return false;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //uncomment this line to see the available fields&lt;br /&gt;
   //var_dump($article);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the same time we get the class suffix from the parameter. Explained below.&lt;br /&gt;
Now that you have the article data, we will change the output file to show it. Remember? /tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
==== default.php - Show article ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After defined(... and the php closing tab we change the html. We use embedded php code to echo the title and the introtext. We add a module specific class $moduleclass sfx to the div tag. $moduleclass sfx is the class suffix the user can add in the Module Manager -&amp;amp;gt; tab Advanced. This can be used for Css styling if multiple instances of the same module are enabled. e.g. you can test to reuse your module by choosing another article. We will style them in the next step.&lt;br /&gt;
&lt;br /&gt;
=== Css styling ===&lt;br /&gt;
Best practice on a website is to &#039;&#039;&#039;try&#039;&#039;&#039; to keep all css styling in one file. As you don&#039;t know if the users template shows your module as designed, you have to include a css file. Not really for what we have above, but in a tutorial we do as if. You should use the parameters we created in a former part, to let the user of the module exclude your css. Described in the Overrides part of the tutorial.&lt;br /&gt;
&lt;br /&gt;
We will not only prepare for loading css but also for images and javascript. Best practice is to store those files in subfolders of the Joomla media folder. Please don&#039;t ask why this folder was named media.&lt;br /&gt;
&lt;br /&gt;
Create folder path/to/your/joomla/media/mod_yourmodule. In the folder where you unpacked the tutorial zip file you&#039;ll find a media folder. Open this and copy all three subfolders to the new folder in your web folder. It should result in something like this &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/logs&lt;br /&gt;
/media&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /css                   *new directory*&lt;br /&gt;
      yourmodule.css       *new file*&lt;br /&gt;
    /images                *new directory*&lt;br /&gt;
      doc.png              *new file*&lt;br /&gt;
      yourmodule-logo.png  *new file*&lt;br /&gt;
    /js                    *new directory*&lt;br /&gt;
      yourmodule.js        *new file*&lt;br /&gt;
      yourmodule_ajax.js   *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/modules&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Did you use your module name? You don´t have to, but it´s a good practice to use distinct names.&lt;br /&gt;
&lt;br /&gt;
=== Add Css file  ===&lt;br /&gt;
&lt;br /&gt;
We include the module specific css file to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
==== default.php - Include Css file and image ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div class=&amp;quot;row text-center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;?php echo JHtml::image(&#039;mod_yourmodule/yourmodule-logo.png&#039;, &#039;Yourmodule logo&#039;, &#039;&#039;, true, false );?&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this code added yourmodule.css will be loaded from the path media/mod_yourmodule/css/&lt;br /&gt;
Be aware of the missing /css/ ! This is added by Joomla. The image will be loaded from the path media/mod_yourmodule/images/.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s test that the css is working by adding a few lines to the yourmodule.css file. Open it with the editor and add e.g. those lines that change text color. Do we have to mention the module name?&lt;br /&gt;
&lt;br /&gt;
==== yourmodule.css ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
.yourmodule h4{&lt;br /&gt;
	color: #08c;&lt;br /&gt;
}&lt;br /&gt;
.yourmodule p {&lt;br /&gt;
	color: #005580;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On your frontend page the colors should have changed and an image added. Have a look! Be aware that your browser may have cached the css.&lt;br /&gt;
&lt;br /&gt;
=== Update the xml and the zip file  ===&lt;br /&gt;
&lt;br /&gt;
Now we have to add the new files to the xml file and create an updated installation zip file.&lt;br /&gt;
&lt;br /&gt;
Add the helper.php and the special media tag to the xml file.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add helper.php ====&lt;br /&gt;
&lt;br /&gt;
Add helper.php to the files tag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;files&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;helper.php&amp;lt;/filename&amp;gt; &lt;br /&gt;
		&amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add media folder ====&lt;br /&gt;
&lt;br /&gt;
Add the media tag between files and languages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
	&amp;lt;media destination=&amp;quot;mod_yourmodule&amp;quot; folder=&amp;quot;media&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;css&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;images&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;js&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/media&amp;gt;&lt;br /&gt;
	&amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== Create the installation file ===&lt;br /&gt;
&lt;br /&gt;
Now you copy &#039;&#039;&#039;all&#039;&#039;&#039; module files from the server to the path &#039;somewhere&#039;/j_module_tutorial/new_module as in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
Create a new folder &#039;media&#039; and copy the three folders from media/mod_yourmodule.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  .../new_module&lt;br /&gt;
      /langs&lt;br /&gt;
        en-GB.mod_yourmodule.ini&lt;br /&gt;
        en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        anyother-language.mod_yourmodule.in&lt;br /&gt;
        anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /language&lt;br /&gt;
        /en-GB&lt;br /&gt;
          en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        /anyother-language&lt;br /&gt;
          anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /media&lt;br /&gt;
        /css&lt;br /&gt;
          yourmodule.css&lt;br /&gt;
        /images&lt;br /&gt;
          doc.png&lt;br /&gt;
          yourmodule-logo.png&lt;br /&gt;
        /js&lt;br /&gt;
          yourmodule.js&lt;br /&gt;
      /tmpl&lt;br /&gt;
        default.php&lt;br /&gt;
      mod_yourmodule.php&lt;br /&gt;
      mod_yourmodule.xml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the compressed installation zip file as described in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this tutorial. Below we describe an alternative for data retrieval.&lt;br /&gt;
&lt;br /&gt;
=== Use a component for data retrieval ===&lt;br /&gt;
&lt;br /&gt;
Below is an alternative to using direct sql. You can use the methods provided by a component to retrieve the data. If you develop your own component, you can prepare methods for reuse, otherwise you can try to find a method in a components models to retrieve the data you want. Here we reuse the getItem method of the content component ( articles ). In this case you get all article data returned. If you use a lot of modules of this type on the same page, be a little aware of momory usage. If you want to test it, you only have to replace the getData method in helper.php.&lt;br /&gt;
&lt;br /&gt;
To see the data available you can uncomment the var_dump line in mod_yourmodule.php.&lt;br /&gt;
&lt;br /&gt;
==== helper.php Use of component ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model = JModelLegacy::getInstance(&#039;Article&#039;, &#039;ContentModel&#039;, array(&#039;ignore_request&#039; =&amp;gt; true));&lt;br /&gt;
&lt;br /&gt;
		$app = JFactory::getApplication(&#039;site&#039;);&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;article.id&#039;, $id);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;list.offset&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
		// Load the parameters.&lt;br /&gt;
		$params = $app-&amp;gt;getParams(&#039;com_content&#039;);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;params&#039;, $params);&lt;br /&gt;
&lt;br /&gt;
		$user = JFactory::getUser();&lt;br /&gt;
&lt;br /&gt;
		if ((!$user-&amp;gt;authorise(&#039;core.edit.state&#039;, &#039;com_content&#039;)) &amp;amp;&amp;amp; (!$user-&amp;gt;authorise(&#039;core.edit&#039;, &#039;com_content&#039;)))&lt;br /&gt;
		{&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.published&#039;, 1);&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.archived&#039;, 2);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;filter.language&#039;, JLanguageMultilang::isEnabled());&lt;br /&gt;
  		&lt;br /&gt;
 		return $model-&amp;gt;getItem($id);;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add javascript to the module ===&lt;br /&gt;
&lt;br /&gt;
If you want to use javascript for yourmodule, here is an example. It loads the javascript file in the media/mod_yourmodule/js path and adds a script to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
Read more [[J3.x:Javascript_Frameworks|J3.x:Javascript Frameworks]]&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
   $document = JFactory::getDocument();&lt;br /&gt;
   $document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this code below the line that loads the css file if you want to test it.&lt;br /&gt;
&lt;br /&gt;
* We use jQuery so we have to load it &#039;&#039;&#039;before&#039;&#039;&#039; our own modulescript. Here we load the Bootstrap framework that also includes jQuery. Use JHtml::_(&#039;jquery.framework&#039;) if you only need this.&lt;br /&gt;
* We add our scriptfile &amp;quot;relative&amp;quot; to the media folder.&lt;br /&gt;
* We add the script declaration directly to the document object. It gets added to the header in the html document.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125244</id>
		<title>User:Over/Step by step to a Joomla Module - Data retrieval and styling</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125244"/>
		<updated>2014-09-07T08:27:54Z</updated>

		<summary type="html">&lt;p&gt;Over: /* default.php Javascript */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to retrieve data from a database table in two ways, direct access to a table and using a components methods. You have to have installed the module you created in former parts of the tutorial, before you start to follow this part.&lt;br /&gt;
&lt;br /&gt;
=== Data retrieval ===&lt;br /&gt;
&lt;br /&gt;
As in the previous parts you copy a skeleton file to your module folder in your Joomla path of the server. This time you copy the helper.php file to the &amp;quot;root&amp;quot; of the module.&lt;br /&gt;
&lt;br /&gt;
==== helper.php ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
abstract class ModYourmoduleHelper&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
		//we will add some code here&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The top of the file looks like any other of our php files. Copy your own comment lines from one of the php files you have edited in the former parts of the tutorial. Then we have a class definition with a name following a convention you as well should follow. Mod + The module name + Helper. A comment block follows describing what the following function does. We will add our code within the function ( in developer language called method ). You have to read the coding standards or have a look in any Joomla! core php file to learn more about coding and commenting conventions.&lt;br /&gt;
&lt;br /&gt;
We will use an article to have a litle more dynamic data example. If you didn&#039;t create an article earlier in this tutorial series do that now. Keep it short as it&#039;s only an example. In the Module Manager you open your module and under the option tab you choose your article example. You see the title but actually the article id number is stored as parameter value.&lt;br /&gt;
&lt;br /&gt;
In the first example we&#039;ll get the article text by sending sql statements to the Joomla! database API.&lt;br /&gt;
&lt;br /&gt;
==== helper.php - The sql commands ====&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		//get the users authorisations&lt;br /&gt;
		$user       = JFactory::getUser();&lt;br /&gt;
		$groups     = implode(&#039;,&#039;, $user-&amp;gt;getAuthorisedViewLevels());&lt;br /&gt;
&lt;br /&gt;
		$db = JFactory::getDbo();&lt;br /&gt;
   		//get a db query object&lt;br /&gt;
		$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
		//select article id, title and introtext&lt;br /&gt;
		$query-&amp;gt;select(&lt;br /&gt;
			array(&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.id&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.title&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.introtext&#039;),&lt;br /&gt;
				)&lt;br /&gt;
		);&lt;br /&gt;
   		//from the article table&lt;br /&gt;
		$query-&amp;gt;from($db-&amp;gt;quoteName(&#039;#__content&#039;, &#039;a&#039;));&lt;br /&gt;
		//id from parameter, we are conservative enough to cast the id&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;id&#039;) . &#039; = &#039;. $db-&amp;gt;quote( (int) $id));&lt;br /&gt;
		// Only return if published&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;a.state&#039;) . &#039; = 1 &#039;);&lt;br /&gt;
		//and user is authorised to read&lt;br /&gt;
		$query-&amp;gt;where(&#039;a.access IN (&#039; . $groups . &#039;)&#039;);&lt;br /&gt;
&lt;br /&gt;
		//uncomment this line to see the query string&lt;br /&gt;
		//echo $query;&lt;br /&gt;
&lt;br /&gt;
		$db-&amp;gt;setQuery($query);&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
	   		//get the article&lt;br /&gt;
			$result = $db-&amp;gt;loadObject();&lt;br /&gt;
		}&lt;br /&gt;
   		//check error&lt;br /&gt;
		catch (RuntimeException $e)&lt;br /&gt;
		{&lt;br /&gt;
			//this is a module so we skip it if there are errors&lt;br /&gt;
			// in other cases we would show a message&lt;br /&gt;
			//$app = JFactory::getApplication();&lt;br /&gt;
			//$app-&amp;gt;enqueueMessage($e-&amp;gt;getMessage(), &#039;error&#039;);&lt;br /&gt;
&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $result;&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the brief comments in the text about what we are doing here. Important security issue: use $db-&amp;amp;gt;quote(&#039;field_value&#039;) to avoid so called &amp;quot;sql-injections&amp;quot;. Be very careful when you build sql queries. We can&#039;t describe the details to Joomla! sql queries within this tutorial. More in [http://docs.joomla.org/Accessing_the_database_using_JDatabase Accessing the database using JDatabase]&lt;br /&gt;
&lt;br /&gt;
As this is a module we don&#039;t show errormessages to the user. If there are errors the page will still be ok.&lt;br /&gt;
&lt;br /&gt;
Copy the code to your helper.php replacing the method ( = function ) getData.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The helper file is loaded and run from mod_yourmodule.php. Open it and add the following between defined(... and require.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.php - Load helper class ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    // Include the helper file that provide the data&lt;br /&gt;
   require_once __DIR__ . &#039;/helper.php&#039;;&lt;br /&gt;
&lt;br /&gt;
   //the class suffix from parameter&lt;br /&gt;
   $moduleclass_sfx = htmlspecialchars($params-&amp;gt;get(&#039;moduleclass_sfx&#039;));&lt;br /&gt;
 &lt;br /&gt;
  if ( !$article = ModYourmoduleHelper::getData($params))&lt;br /&gt;
   {&lt;br /&gt;
      //if error or article not found skip this module&lt;br /&gt;
      return false;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //uncomment this line to see the available fields&lt;br /&gt;
   //var_dump($article);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the same time we get the class suffix from the parameter. Explained below.&lt;br /&gt;
Now that you have the article data, we will change the output file to show it. Remember? /tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
==== default.php - Show article ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After defined(... and the php closing tab we change the html. We use embedded php code to echo the title and the introtext. We add a module specific class $moduleclass sfx to the div tag. $moduleclass sfx is the class suffix the user can add in the Module Manager -&amp;amp;gt; tab Advanced. This can be used for Css styling if multiple instances of the same module are enabled. e.g. you can test to reuse your module by choosing another article. We will style them in the next step.&lt;br /&gt;
&lt;br /&gt;
=== Css styling ===&lt;br /&gt;
Best practice on a website is to &#039;&#039;&#039;try&#039;&#039;&#039; to keep all css styling in one file. As you don&#039;t know if the users template shows your module as designed, you have to include a css file. Not really for what we have above, but in a tutorial we do as if. You should use the parameters we created in a former part, to let the user of the module exclude your css. Described in the Overrides part of the tutorial.&lt;br /&gt;
&lt;br /&gt;
We will not only prepare for loading css but also for images and javascript. Best practice is to store those files in subfolders of the Joomla media folder. Please don&#039;t ask why this folder was named media.&lt;br /&gt;
&lt;br /&gt;
Create folder path/to/your/joomla/media/mod_yourmodule. In the folder where you unpacked the tutorial zip file you&#039;ll find a media folder. Open this and copy all three subfolders to the new folder in your web folder. It should result in something like this &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/logs&lt;br /&gt;
/media&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /css                   *new directory*&lt;br /&gt;
      yourmodule.css       *new file*&lt;br /&gt;
    /images                *new directory*&lt;br /&gt;
      doc.png              *new file*&lt;br /&gt;
      yourmodule-logo.png  *new file*&lt;br /&gt;
    /js                    *new directory*&lt;br /&gt;
      yourmodule.js        *new file*&lt;br /&gt;
      yourmodule_ajax.js   *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/modules&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Did you use your module name? You don´t have to, but it´s a good practice to use distinct names.&lt;br /&gt;
&lt;br /&gt;
=== Add Css file  ===&lt;br /&gt;
&lt;br /&gt;
We include the module specific css file to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
==== default.php - Include Css file and image ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div class=&amp;quot;row text-center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;?php echo JHtml::image(&#039;mod_yourmodule/yourmodule-logo.png&#039;, &#039;Yourmodule logo&#039;, &#039;&#039;, true, false );?&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this code added yourmodule.css will be loaded from the path media/mod_yourmodule/css/&lt;br /&gt;
Be aware of the missing /css/ ! This is added by Joomla. The image will be loaded from the path media/mod_yourmodule/images/.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s test that the css is working by adding a few lines to the yourmodule.css file. Open it with the editor and add e.g. those lines that change text color. Do we have to mention the module name?&lt;br /&gt;
&lt;br /&gt;
==== yourmodule.css ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
.yourmodule h4{&lt;br /&gt;
	color: #08c;&lt;br /&gt;
}&lt;br /&gt;
.yourmodule p {&lt;br /&gt;
	color: #005580;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On your frontend page the colors should have changed and an image added. Have a look! Be aware that your browser may have cached the css.&lt;br /&gt;
&lt;br /&gt;
=== Update the xml and the zip file  ===&lt;br /&gt;
&lt;br /&gt;
Now we have to add the new files to the xml file and create an updated installation zip file.&lt;br /&gt;
&lt;br /&gt;
Add the helper.php and the special media tag to the xml file.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add helper.php ====&lt;br /&gt;
&lt;br /&gt;
Add helper.php to the files tag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;files&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;helper.php&amp;lt;/filename&amp;gt; &lt;br /&gt;
		&amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add media folder ====&lt;br /&gt;
&lt;br /&gt;
Add the media tag between files and languages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
	&amp;lt;media destination=&amp;quot;mod_yourmodule&amp;quot; folder=&amp;quot;media&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;css&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;images&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;js&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/media&amp;gt;&lt;br /&gt;
	&amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== Create the installation file ===&lt;br /&gt;
&lt;br /&gt;
Now you copy &#039;&#039;&#039;all&#039;&#039;&#039; module files from the server to the path &#039;somewhere&#039;/j_module_tutorial/new_module as in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
Create a new folder &#039;media&#039; and copy the three folders from media/mod_yourmodule.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  .../new_module&lt;br /&gt;
      /langs&lt;br /&gt;
        en-GB.mod_yourmodule.ini&lt;br /&gt;
        en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        anyother-language.mod_yourmodule.in&lt;br /&gt;
        anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /language&lt;br /&gt;
        /en-GB&lt;br /&gt;
          en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        /anyother-language&lt;br /&gt;
          anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /media&lt;br /&gt;
        /css&lt;br /&gt;
          yourmodule.css&lt;br /&gt;
        /images&lt;br /&gt;
          doc.png&lt;br /&gt;
          yourmodule-logo.png&lt;br /&gt;
        /js&lt;br /&gt;
          yourmodule.js&lt;br /&gt;
      /tmpl&lt;br /&gt;
        default.php&lt;br /&gt;
      mod_yourmodule.php&lt;br /&gt;
      mod_yourmodule.xml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the compressed installation zip file as described in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this tutorial. Below we describe an alternative for data retrieval.&lt;br /&gt;
&lt;br /&gt;
=== Use a component for data retrieval ===&lt;br /&gt;
&lt;br /&gt;
Below is an alternative to using direct sql. You can use the methods provided by a component to retrieve the data. If you develop your own component, you can prepare methods for reuse, otherwise you can try to find a method in a components models to retrieve the data you want. Here we reuse the getItem method of the content component ( articles ). In this case you get all article data returned so be a little aware of momory usage. If you want to test it, you only have to replace the getData method in helper.php&lt;br /&gt;
&lt;br /&gt;
==== helper.php Use of component ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model = JModelLegacy::getInstance(&#039;Article&#039;, &#039;ContentModel&#039;, array(&#039;ignore_request&#039; =&amp;gt; true));&lt;br /&gt;
&lt;br /&gt;
		$app = JFactory::getApplication(&#039;site&#039;);&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;article.id&#039;, $id);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;list.offset&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
		// Load the parameters.&lt;br /&gt;
		$params = $app-&amp;gt;getParams(&#039;com_content&#039;);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;params&#039;, $params);&lt;br /&gt;
&lt;br /&gt;
		$user = JFactory::getUser();&lt;br /&gt;
&lt;br /&gt;
		if ((!$user-&amp;gt;authorise(&#039;core.edit.state&#039;, &#039;com_content&#039;)) &amp;amp;&amp;amp; (!$user-&amp;gt;authorise(&#039;core.edit&#039;, &#039;com_content&#039;)))&lt;br /&gt;
		{&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.published&#039;, 1);&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.archived&#039;, 2);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;filter.language&#039;, JLanguageMultilang::isEnabled());&lt;br /&gt;
  		&lt;br /&gt;
 		return $model-&amp;gt;getItem($id);;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add javascript to the module ===&lt;br /&gt;
&lt;br /&gt;
If you want to use javascript for yourmodule, here is an example. It loads the javascript file in the media/mod_yourmodule/js path and adds a script to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
Read more [[J3.x:Javascript_Frameworks|J3.x:Javascript Frameworks]]&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
   $document = JFactory::getDocument();&lt;br /&gt;
   $document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this code below the line that loads the css file if you want to test it.&lt;br /&gt;
&lt;br /&gt;
* We use jQuery so we have to load it &#039;&#039;&#039;before&#039;&#039;&#039; our own modulescript. Here we load the Bootstrap framework that also includes jQuery. Use JHtml::_(&#039;jquery.framework&#039;) if you only need this.&lt;br /&gt;
* We add our scriptfile &amp;quot;relative&amp;quot; to the media folder.&lt;br /&gt;
* We add the script declaration directly to the document object. It gets added to the header in the html document.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125243</id>
		<title>User:Over/Step by step to a Joomla Module - Data retrieval and styling</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125243"/>
		<updated>2014-09-07T08:21:40Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Css styling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to retrieve data from a database table in two ways, direct access to a table and using a components methods. You have to have installed the module you created in former parts of the tutorial, before you start to follow this part.&lt;br /&gt;
&lt;br /&gt;
=== Data retrieval ===&lt;br /&gt;
&lt;br /&gt;
As in the previous parts you copy a skeleton file to your module folder in your Joomla path of the server. This time you copy the helper.php file to the &amp;quot;root&amp;quot; of the module.&lt;br /&gt;
&lt;br /&gt;
==== helper.php ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
abstract class ModYourmoduleHelper&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
		//we will add some code here&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The top of the file looks like any other of our php files. Copy your own comment lines from one of the php files you have edited in the former parts of the tutorial. Then we have a class definition with a name following a convention you as well should follow. Mod + The module name + Helper. A comment block follows describing what the following function does. We will add our code within the function ( in developer language called method ). You have to read the coding standards or have a look in any Joomla! core php file to learn more about coding and commenting conventions.&lt;br /&gt;
&lt;br /&gt;
We will use an article to have a litle more dynamic data example. If you didn&#039;t create an article earlier in this tutorial series do that now. Keep it short as it&#039;s only an example. In the Module Manager you open your module and under the option tab you choose your article example. You see the title but actually the article id number is stored as parameter value.&lt;br /&gt;
&lt;br /&gt;
In the first example we&#039;ll get the article text by sending sql statements to the Joomla! database API.&lt;br /&gt;
&lt;br /&gt;
==== helper.php - The sql commands ====&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		//get the users authorisations&lt;br /&gt;
		$user       = JFactory::getUser();&lt;br /&gt;
		$groups     = implode(&#039;,&#039;, $user-&amp;gt;getAuthorisedViewLevels());&lt;br /&gt;
&lt;br /&gt;
		$db = JFactory::getDbo();&lt;br /&gt;
   		//get a db query object&lt;br /&gt;
		$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
		//select article id, title and introtext&lt;br /&gt;
		$query-&amp;gt;select(&lt;br /&gt;
			array(&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.id&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.title&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.introtext&#039;),&lt;br /&gt;
				)&lt;br /&gt;
		);&lt;br /&gt;
   		//from the article table&lt;br /&gt;
		$query-&amp;gt;from($db-&amp;gt;quoteName(&#039;#__content&#039;, &#039;a&#039;));&lt;br /&gt;
		//id from parameter, we are conservative enough to cast the id&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;id&#039;) . &#039; = &#039;. $db-&amp;gt;quote( (int) $id));&lt;br /&gt;
		// Only return if published&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;a.state&#039;) . &#039; = 1 &#039;);&lt;br /&gt;
		//and user is authorised to read&lt;br /&gt;
		$query-&amp;gt;where(&#039;a.access IN (&#039; . $groups . &#039;)&#039;);&lt;br /&gt;
&lt;br /&gt;
		//uncomment this line to see the query string&lt;br /&gt;
		//echo $query;&lt;br /&gt;
&lt;br /&gt;
		$db-&amp;gt;setQuery($query);&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
	   		//get the article&lt;br /&gt;
			$result = $db-&amp;gt;loadObject();&lt;br /&gt;
		}&lt;br /&gt;
   		//check error&lt;br /&gt;
		catch (RuntimeException $e)&lt;br /&gt;
		{&lt;br /&gt;
			//this is a module so we skip it if there are errors&lt;br /&gt;
			// in other cases we would show a message&lt;br /&gt;
			//$app = JFactory::getApplication();&lt;br /&gt;
			//$app-&amp;gt;enqueueMessage($e-&amp;gt;getMessage(), &#039;error&#039;);&lt;br /&gt;
&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $result;&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the brief comments in the text about what we are doing here. Important security issue: use $db-&amp;amp;gt;quote(&#039;field_value&#039;) to avoid so called &amp;quot;sql-injections&amp;quot;. Be very careful when you build sql queries. We can&#039;t describe the details to Joomla! sql queries within this tutorial. More in [http://docs.joomla.org/Accessing_the_database_using_JDatabase Accessing the database using JDatabase]&lt;br /&gt;
&lt;br /&gt;
As this is a module we don&#039;t show errormessages to the user. If there are errors the page will still be ok.&lt;br /&gt;
&lt;br /&gt;
Copy the code to your helper.php replacing the method ( = function ) getData.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The helper file is loaded and run from mod_yourmodule.php. Open it and add the following between defined(... and require.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.php - Load helper class ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    // Include the helper file that provide the data&lt;br /&gt;
   require_once __DIR__ . &#039;/helper.php&#039;;&lt;br /&gt;
&lt;br /&gt;
   //the class suffix from parameter&lt;br /&gt;
   $moduleclass_sfx = htmlspecialchars($params-&amp;gt;get(&#039;moduleclass_sfx&#039;));&lt;br /&gt;
 &lt;br /&gt;
  if ( !$article = ModYourmoduleHelper::getData($params))&lt;br /&gt;
   {&lt;br /&gt;
      //if error or article not found skip this module&lt;br /&gt;
      return false;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //uncomment this line to see the available fields&lt;br /&gt;
   //var_dump($article);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the same time we get the class suffix from the parameter. Explained below.&lt;br /&gt;
Now that you have the article data, we will change the output file to show it. Remember? /tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
==== default.php - Show article ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After defined(... and the php closing tab we change the html. We use embedded php code to echo the title and the introtext. We add a module specific class $moduleclass sfx to the div tag. $moduleclass sfx is the class suffix the user can add in the Module Manager -&amp;amp;gt; tab Advanced. This can be used for Css styling if multiple instances of the same module are enabled. e.g. you can test to reuse your module by choosing another article. We will style them in the next step.&lt;br /&gt;
&lt;br /&gt;
=== Css styling ===&lt;br /&gt;
Best practice on a website is to &#039;&#039;&#039;try&#039;&#039;&#039; to keep all css styling in one file. As you don&#039;t know if the users template shows your module as designed, you have to include a css file. Not really for what we have above, but in a tutorial we do as if. You should use the parameters we created in a former part, to let the user of the module exclude your css. Described in the Overrides part of the tutorial.&lt;br /&gt;
&lt;br /&gt;
We will not only prepare for loading css but also for images and javascript. Best practice is to store those files in subfolders of the Joomla media folder. Please don&#039;t ask why this folder was named media.&lt;br /&gt;
&lt;br /&gt;
Create folder path/to/your/joomla/media/mod_yourmodule. In the folder where you unpacked the tutorial zip file you&#039;ll find a media folder. Open this and copy all three subfolders to the new folder in your web folder. It should result in something like this &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/logs&lt;br /&gt;
/media&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /css                   *new directory*&lt;br /&gt;
      yourmodule.css       *new file*&lt;br /&gt;
    /images                *new directory*&lt;br /&gt;
      doc.png              *new file*&lt;br /&gt;
      yourmodule-logo.png  *new file*&lt;br /&gt;
    /js                    *new directory*&lt;br /&gt;
      yourmodule.js        *new file*&lt;br /&gt;
      yourmodule_ajax.js   *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/modules&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Did you use your module name? You don´t have to, but it´s a good practice to use distinct names.&lt;br /&gt;
&lt;br /&gt;
=== Add Css file  ===&lt;br /&gt;
&lt;br /&gt;
We include the module specific css file to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
==== default.php - Include Css file and image ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div class=&amp;quot;row text-center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;?php echo JHtml::image(&#039;mod_yourmodule/yourmodule-logo.png&#039;, &#039;Yourmodule logo&#039;, &#039;&#039;, true, false );?&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this code added yourmodule.css will be loaded from the path media/mod_yourmodule/css/&lt;br /&gt;
Be aware of the missing /css/ ! This is added by Joomla. The image will be loaded from the path media/mod_yourmodule/images/.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s test that the css is working by adding a few lines to the yourmodule.css file. Open it with the editor and add e.g. those lines that change text color. Do we have to mention the module name?&lt;br /&gt;
&lt;br /&gt;
==== yourmodule.css ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
.yourmodule h4{&lt;br /&gt;
	color: #08c;&lt;br /&gt;
}&lt;br /&gt;
.yourmodule p {&lt;br /&gt;
	color: #005580;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On your frontend page the colors should have changed and an image added. Have a look! Be aware that your browser may have cached the css.&lt;br /&gt;
&lt;br /&gt;
=== Update the xml and the zip file  ===&lt;br /&gt;
&lt;br /&gt;
Now we have to add the new files to the xml file and create an updated installation zip file.&lt;br /&gt;
&lt;br /&gt;
Add the helper.php and the special media tag to the xml file.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add helper.php ====&lt;br /&gt;
&lt;br /&gt;
Add helper.php to the files tag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;files&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;helper.php&amp;lt;/filename&amp;gt; &lt;br /&gt;
		&amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add media folder ====&lt;br /&gt;
&lt;br /&gt;
Add the media tag between files and languages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
	&amp;lt;media destination=&amp;quot;mod_yourmodule&amp;quot; folder=&amp;quot;media&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;css&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;images&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;js&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/media&amp;gt;&lt;br /&gt;
	&amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== Create the installation file ===&lt;br /&gt;
&lt;br /&gt;
Now you copy &#039;&#039;&#039;all&#039;&#039;&#039; module files from the server to the path &#039;somewhere&#039;/j_module_tutorial/new_module as in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
Create a new folder &#039;media&#039; and copy the three folders from media/mod_yourmodule.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  .../new_module&lt;br /&gt;
      /langs&lt;br /&gt;
        en-GB.mod_yourmodule.ini&lt;br /&gt;
        en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        anyother-language.mod_yourmodule.in&lt;br /&gt;
        anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /language&lt;br /&gt;
        /en-GB&lt;br /&gt;
          en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        /anyother-language&lt;br /&gt;
          anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /media&lt;br /&gt;
        /css&lt;br /&gt;
          yourmodule.css&lt;br /&gt;
        /images&lt;br /&gt;
          doc.png&lt;br /&gt;
          yourmodule-logo.png&lt;br /&gt;
        /js&lt;br /&gt;
          yourmodule.js&lt;br /&gt;
      /tmpl&lt;br /&gt;
        default.php&lt;br /&gt;
      mod_yourmodule.php&lt;br /&gt;
      mod_yourmodule.xml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the compressed installation zip file as described in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this tutorial. Below we describe an alternative for data retrieval.&lt;br /&gt;
&lt;br /&gt;
=== Use a component for data retrieval ===&lt;br /&gt;
&lt;br /&gt;
Below is an alternative to using direct sql. You can use the methods provided by a component to retrieve the data. If you develop your own component, you can prepare methods for reuse, otherwise you can try to find a method in a components models to retrieve the data you want. Here we reuse the getItem method of the content component ( articles ). In this case you get all article data returned so be a little aware of momory usage. If you want to test it, you only have to replace the getData method in helper.php&lt;br /&gt;
&lt;br /&gt;
==== helper.php Use of component ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model = JModelLegacy::getInstance(&#039;Article&#039;, &#039;ContentModel&#039;, array(&#039;ignore_request&#039; =&amp;gt; true));&lt;br /&gt;
&lt;br /&gt;
		$app = JFactory::getApplication(&#039;site&#039;);&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;article.id&#039;, $id);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;list.offset&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
		// Load the parameters.&lt;br /&gt;
		$params = $app-&amp;gt;getParams(&#039;com_content&#039;);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;params&#039;, $params);&lt;br /&gt;
&lt;br /&gt;
		$user = JFactory::getUser();&lt;br /&gt;
&lt;br /&gt;
		if ((!$user-&amp;gt;authorise(&#039;core.edit.state&#039;, &#039;com_content&#039;)) &amp;amp;&amp;amp; (!$user-&amp;gt;authorise(&#039;core.edit&#039;, &#039;com_content&#039;)))&lt;br /&gt;
		{&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.published&#039;, 1);&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.archived&#039;, 2);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;filter.language&#039;, JLanguageMultilang::isEnabled());&lt;br /&gt;
  		&lt;br /&gt;
 		return $model-&amp;gt;getItem($id);;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add javascript to the module ===&lt;br /&gt;
&lt;br /&gt;
If you want to use javascript for yourmodule, here is an example. It loads the javascript file in the media/mod_yourmodule/js path and adds a script to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
Read more [[J3.x:Javascript_Frameworks|J3.x:Javascript Frameworks]]&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
$document = JFactory::getDocument();&lt;br /&gt;
$document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this code below the line that loads the css file if you want to test it.&lt;br /&gt;
&lt;br /&gt;
* We use jQuery so we have to load it &#039;&#039;&#039;before&#039;&#039;&#039; our own modulescript. Here we load the Bootstrap framework that also includes jQuery. Use JHtml::_(&#039;jquery.framework&#039;) if you only need this.&lt;br /&gt;
* We add our scriptfile &amp;quot;relative&amp;quot; to the media folder.&lt;br /&gt;
* We add the script declaration directly to the document object. It gets added to the header in the html document.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125242</id>
		<title>User:Over/Step by step to a Joomla Module - Data retrieval and styling</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125242"/>
		<updated>2014-09-07T08:09:55Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Css styling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to retrieve data from a database table in two ways, direct access to a table and using a components methods. You have to have installed the module you created in former parts of the tutorial, before you start to follow this part.&lt;br /&gt;
&lt;br /&gt;
=== Data retrieval ===&lt;br /&gt;
&lt;br /&gt;
As in the previous parts you copy a skeleton file to your module folder in your Joomla path of the server. This time you copy the helper.php file to the &amp;quot;root&amp;quot; of the module.&lt;br /&gt;
&lt;br /&gt;
==== helper.php ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
abstract class ModYourmoduleHelper&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
		//we will add some code here&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The top of the file looks like any other of our php files. Copy your own comment lines from one of the php files you have edited in the former parts of the tutorial. Then we have a class definition with a name following a convention you as well should follow. Mod + The module name + Helper. A comment block follows describing what the following function does. We will add our code within the function ( in developer language called method ). You have to read the coding standards or have a look in any Joomla! core php file to learn more about coding and commenting conventions.&lt;br /&gt;
&lt;br /&gt;
We will use an article to have a litle more dynamic data example. If you didn&#039;t create an article earlier in this tutorial series do that now. Keep it short as it&#039;s only an example. In the Module Manager you open your module and under the option tab you choose your article example. You see the title but actually the article id number is stored as parameter value.&lt;br /&gt;
&lt;br /&gt;
In the first example we&#039;ll get the article text by sending sql statements to the Joomla! database API.&lt;br /&gt;
&lt;br /&gt;
==== helper.php - The sql commands ====&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		//get the users authorisations&lt;br /&gt;
		$user       = JFactory::getUser();&lt;br /&gt;
		$groups     = implode(&#039;,&#039;, $user-&amp;gt;getAuthorisedViewLevels());&lt;br /&gt;
&lt;br /&gt;
		$db = JFactory::getDbo();&lt;br /&gt;
   		//get a db query object&lt;br /&gt;
		$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
		//select article id, title and introtext&lt;br /&gt;
		$query-&amp;gt;select(&lt;br /&gt;
			array(&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.id&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.title&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.introtext&#039;),&lt;br /&gt;
				)&lt;br /&gt;
		);&lt;br /&gt;
   		//from the article table&lt;br /&gt;
		$query-&amp;gt;from($db-&amp;gt;quoteName(&#039;#__content&#039;, &#039;a&#039;));&lt;br /&gt;
		//id from parameter, we are conservative enough to cast the id&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;id&#039;) . &#039; = &#039;. $db-&amp;gt;quote( (int) $id));&lt;br /&gt;
		// Only return if published&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;a.state&#039;) . &#039; = 1 &#039;);&lt;br /&gt;
		//and user is authorised to read&lt;br /&gt;
		$query-&amp;gt;where(&#039;a.access IN (&#039; . $groups . &#039;)&#039;);&lt;br /&gt;
&lt;br /&gt;
		//uncomment this line to see the query string&lt;br /&gt;
		//echo $query;&lt;br /&gt;
&lt;br /&gt;
		$db-&amp;gt;setQuery($query);&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
	   		//get the article&lt;br /&gt;
			$result = $db-&amp;gt;loadObject();&lt;br /&gt;
		}&lt;br /&gt;
   		//check error&lt;br /&gt;
		catch (RuntimeException $e)&lt;br /&gt;
		{&lt;br /&gt;
			//this is a module so we skip it if there are errors&lt;br /&gt;
			// in other cases we would show a message&lt;br /&gt;
			//$app = JFactory::getApplication();&lt;br /&gt;
			//$app-&amp;gt;enqueueMessage($e-&amp;gt;getMessage(), &#039;error&#039;);&lt;br /&gt;
&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $result;&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the brief comments in the text about what we are doing here. Important security issue: use $db-&amp;amp;gt;quote(&#039;field_value&#039;) to avoid so called &amp;quot;sql-injections&amp;quot;. Be very careful when you build sql queries. We can&#039;t describe the details to Joomla! sql queries within this tutorial. More in [http://docs.joomla.org/Accessing_the_database_using_JDatabase Accessing the database using JDatabase]&lt;br /&gt;
&lt;br /&gt;
As this is a module we don&#039;t show errormessages to the user. If there are errors the page will still be ok.&lt;br /&gt;
&lt;br /&gt;
Copy the code to your helper.php replacing the method ( = function ) getData.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The helper file is loaded and run from mod_yourmodule.php. Open it and add the following between defined(... and require.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.php - Load helper class ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    // Include the helper file that provide the data&lt;br /&gt;
   require_once __DIR__ . &#039;/helper.php&#039;;&lt;br /&gt;
&lt;br /&gt;
   //the class suffix from parameter&lt;br /&gt;
   $moduleclass_sfx = htmlspecialchars($params-&amp;gt;get(&#039;moduleclass_sfx&#039;));&lt;br /&gt;
 &lt;br /&gt;
  if ( !$article = ModYourmoduleHelper::getData($params))&lt;br /&gt;
   {&lt;br /&gt;
      //if error or article not found skip this module&lt;br /&gt;
      return false;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //uncomment this line to see the available fields&lt;br /&gt;
   //var_dump($article);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the same time we get the class suffix from the parameter. Explained below.&lt;br /&gt;
Now that you have the article data, we will change the output file to show it. Remember? /tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
==== default.php - Show article ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After defined(... and the php closing tab we change the html. We use embedded php code to echo the title and the introtext. We add a module specific class $moduleclass sfx to the div tag. $moduleclass sfx is the class suffix the user can add in the Module Manager -&amp;amp;gt; tab Advanced. This can be used for Css styling if multiple instances of the same module are enabled. e.g. you can test to reuse your module by choosing another article. We will style them in the next step.&lt;br /&gt;
&lt;br /&gt;
=== Css styling ===&lt;br /&gt;
Best practice on a website is to &#039;&#039;&#039;try&#039;&#039;&#039; to keep all css styling in one file. As you don&#039;t know if the users template shows your module as designed you have to include a css file. Not really for what we have above but in a tutorial we do as if.&lt;br /&gt;
&lt;br /&gt;
We will not only prepare for loading css but also for images and javascript. Best practice is to store those files in subfolders of the Joomla media folder. Please don&#039;t ask why this folder was named media.&lt;br /&gt;
&lt;br /&gt;
Create folder path/to/your/joomla/media/mod_yourmodule. In the folder where you unpacked the tutorial zip file you&#039;ll find a media folder. Open this and copy all three subfolders to the new folder in your web folder. It should result in something like this &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/logs&lt;br /&gt;
/media&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /css                   *new directory*&lt;br /&gt;
      yourmodule.css       *new file*&lt;br /&gt;
    /images                *new directory*&lt;br /&gt;
      doc.png              *new file*&lt;br /&gt;
      yourmodule-logo.png  *new file*&lt;br /&gt;
    /js                    *new directory*&lt;br /&gt;
      yourmodule.js        *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/modules&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Did you use your module name? You don´t have to, but it´s a good practice to use distinct names.&lt;br /&gt;
&lt;br /&gt;
=== Add Css file  ===&lt;br /&gt;
&lt;br /&gt;
We include the module specific css file to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
==== default.php - Include Css file and image ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div class=&amp;quot;row text-center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;?php echo JHtml::image(&#039;mod_yourmodule/yourmodule-logo.png&#039;, &#039;Yourmodule logo&#039;, &#039;&#039;, true, false );?&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this code added yourmodule.css will be loaded from the path media/mod_yourmodule/css/&lt;br /&gt;
Be aware of the missing /css/ ! This is added by Joomla. The image will be loaded from the path media/mod_yourmodule/images/.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s test that the css is working by adding a few lines to the yourmodule.css file. Open it with the editor and add e.g. those lines that change text color. Do we have to mention the module name?&lt;br /&gt;
&lt;br /&gt;
==== yourmodule.css ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
.yourmodule h4{&lt;br /&gt;
	color: #08c;&lt;br /&gt;
}&lt;br /&gt;
.yourmodule p {&lt;br /&gt;
	color: #005580;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On your frontend page the colors should have changed and an image added. Have a look! Be aware that your browser may have cached the css.&lt;br /&gt;
&lt;br /&gt;
=== Update the xml and the zip file  ===&lt;br /&gt;
&lt;br /&gt;
Now we have to add the new files to the xml file and create an updated installation zip file.&lt;br /&gt;
&lt;br /&gt;
Add the helper.php and the special media tag to the xml file.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add helper.php ====&lt;br /&gt;
&lt;br /&gt;
Add helper.php to the files tag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;files&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;helper.php&amp;lt;/filename&amp;gt; &lt;br /&gt;
		&amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add media folder ====&lt;br /&gt;
&lt;br /&gt;
Add the media tag between files and languages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
	&amp;lt;media destination=&amp;quot;mod_yourmodule&amp;quot; folder=&amp;quot;media&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;css&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;images&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;js&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/media&amp;gt;&lt;br /&gt;
	&amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== Create the installation file ===&lt;br /&gt;
&lt;br /&gt;
Now you copy &#039;&#039;&#039;all&#039;&#039;&#039; module files from the server to the path &#039;somewhere&#039;/j_module_tutorial/new_module as in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
Create a new folder &#039;media&#039; and copy the three folders from media/mod_yourmodule.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  .../new_module&lt;br /&gt;
      /langs&lt;br /&gt;
        en-GB.mod_yourmodule.ini&lt;br /&gt;
        en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        anyother-language.mod_yourmodule.in&lt;br /&gt;
        anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /language&lt;br /&gt;
        /en-GB&lt;br /&gt;
          en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        /anyother-language&lt;br /&gt;
          anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /media&lt;br /&gt;
        /css&lt;br /&gt;
          yourmodule.css&lt;br /&gt;
        /images&lt;br /&gt;
          doc.png&lt;br /&gt;
          yourmodule-logo.png&lt;br /&gt;
        /js&lt;br /&gt;
          yourmodule.js&lt;br /&gt;
      /tmpl&lt;br /&gt;
        default.php&lt;br /&gt;
      mod_yourmodule.php&lt;br /&gt;
      mod_yourmodule.xml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the compressed installation zip file as described in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this tutorial. Below we describe an alternative for data retrieval.&lt;br /&gt;
&lt;br /&gt;
=== Use a component for data retrieval ===&lt;br /&gt;
&lt;br /&gt;
Below is an alternative to using direct sql. You can use the methods provided by a component to retrieve the data. If you develop your own component, you can prepare methods for reuse, otherwise you can try to find a method in a components models to retrieve the data you want. Here we reuse the getItem method of the content component ( articles ). In this case you get all article data returned so be a little aware of momory usage. If you want to test it, you only have to replace the getData method in helper.php&lt;br /&gt;
&lt;br /&gt;
==== helper.php Use of component ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model = JModelLegacy::getInstance(&#039;Article&#039;, &#039;ContentModel&#039;, array(&#039;ignore_request&#039; =&amp;gt; true));&lt;br /&gt;
&lt;br /&gt;
		$app = JFactory::getApplication(&#039;site&#039;);&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;article.id&#039;, $id);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;list.offset&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
		// Load the parameters.&lt;br /&gt;
		$params = $app-&amp;gt;getParams(&#039;com_content&#039;);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;params&#039;, $params);&lt;br /&gt;
&lt;br /&gt;
		$user = JFactory::getUser();&lt;br /&gt;
&lt;br /&gt;
		if ((!$user-&amp;gt;authorise(&#039;core.edit.state&#039;, &#039;com_content&#039;)) &amp;amp;&amp;amp; (!$user-&amp;gt;authorise(&#039;core.edit&#039;, &#039;com_content&#039;)))&lt;br /&gt;
		{&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.published&#039;, 1);&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.archived&#039;, 2);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;filter.language&#039;, JLanguageMultilang::isEnabled());&lt;br /&gt;
  		&lt;br /&gt;
 		return $model-&amp;gt;getItem($id);;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add javascript to the module ===&lt;br /&gt;
&lt;br /&gt;
If you want to use javascript for yourmodule, here is an example. It loads the javascript file in the media/mod_yourmodule/js path and adds a script to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
Read more [[J3.x:Javascript_Frameworks|J3.x:Javascript Frameworks]]&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
$document = JFactory::getDocument();&lt;br /&gt;
$document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this code below the line that loads the css file if you want to test it.&lt;br /&gt;
&lt;br /&gt;
* We use jQuery so we have to load it &#039;&#039;&#039;before&#039;&#039;&#039; our own modulescript. Here we load the Bootstrap framework that also includes jQuery. Use JHtml::_(&#039;jquery.framework&#039;) if you only need this.&lt;br /&gt;
* We add our scriptfile &amp;quot;relative&amp;quot; to the media folder.&lt;br /&gt;
* We add the script declaration directly to the document object. It gets added to the header in the html document.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125241</id>
		<title>User:Over/Step by step to a Joomla Module - Data retrieval and styling</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Data_retrieval_and_styling&amp;diff=125241"/>
		<updated>2014-09-07T08:01:20Z</updated>

		<summary type="html">&lt;p&gt;Over: /* mod_yourmodule.php - Load helper class */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to retrieve data from a database table in two ways, direct access to a table and using a components methods. You have to have installed the module you created in former parts of the tutorial, before you start to follow this part.&lt;br /&gt;
&lt;br /&gt;
=== Data retrieval ===&lt;br /&gt;
&lt;br /&gt;
As in the previous parts you copy a skeleton file to your module folder in your Joomla path of the server. This time you copy the helper.php file to the &amp;quot;root&amp;quot; of the module.&lt;br /&gt;
&lt;br /&gt;
==== helper.php ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
abstract class ModYourmoduleHelper&lt;br /&gt;
{&lt;br /&gt;
	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
		//we will add some code here&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The top of the file looks like any other of our php files. Copy your own comment lines from one of the php files you have edited in the former parts of the tutorial. Then we have a class definition with a name following a convention you as well should follow. Mod + The module name + Helper. A comment block follows describing what the following function does. We will add our code within the function ( in developer language called method ). You have to read the coding standards or have a look in any Joomla! core php file to learn more about coding and commenting conventions.&lt;br /&gt;
&lt;br /&gt;
We will use an article to have a litle more dynamic data example. If you didn&#039;t create an article earlier in this tutorial series do that now. Keep it short as it&#039;s only an example. In the Module Manager you open your module and under the option tab you choose your article example. You see the title but actually the article id number is stored as parameter value.&lt;br /&gt;
&lt;br /&gt;
In the first example we&#039;ll get the article text by sending sql statements to the Joomla! database API.&lt;br /&gt;
&lt;br /&gt;
==== helper.php - The sql commands ====&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   	/**&lt;br /&gt;
	 * Get data from table&lt;br /&gt;
	 * @return  array&lt;br /&gt;
	 */&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
		//get the users authorisations&lt;br /&gt;
		$user       = JFactory::getUser();&lt;br /&gt;
		$groups     = implode(&#039;,&#039;, $user-&amp;gt;getAuthorisedViewLevels());&lt;br /&gt;
&lt;br /&gt;
		$db = JFactory::getDbo();&lt;br /&gt;
   		//get a db query object&lt;br /&gt;
		$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
		//select article id, title and introtext&lt;br /&gt;
		$query-&amp;gt;select(&lt;br /&gt;
			array(&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.id&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.title&#039;),&lt;br /&gt;
				$db-&amp;gt;quoteName(&#039;a.introtext&#039;),&lt;br /&gt;
				)&lt;br /&gt;
		);&lt;br /&gt;
   		//from the article table&lt;br /&gt;
		$query-&amp;gt;from($db-&amp;gt;quoteName(&#039;#__content&#039;, &#039;a&#039;));&lt;br /&gt;
		//id from parameter, we are conservative enough to cast the id&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;id&#039;) . &#039; = &#039;. $db-&amp;gt;quote( (int) $id));&lt;br /&gt;
		// Only return if published&lt;br /&gt;
		$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;a.state&#039;) . &#039; = 1 &#039;);&lt;br /&gt;
		//and user is authorised to read&lt;br /&gt;
		$query-&amp;gt;where(&#039;a.access IN (&#039; . $groups . &#039;)&#039;);&lt;br /&gt;
&lt;br /&gt;
		//uncomment this line to see the query string&lt;br /&gt;
		//echo $query;&lt;br /&gt;
&lt;br /&gt;
		$db-&amp;gt;setQuery($query);&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
	   		//get the article&lt;br /&gt;
			$result = $db-&amp;gt;loadObject();&lt;br /&gt;
		}&lt;br /&gt;
   		//check error&lt;br /&gt;
		catch (RuntimeException $e)&lt;br /&gt;
		{&lt;br /&gt;
			//this is a module so we skip it if there are errors&lt;br /&gt;
			// in other cases we would show a message&lt;br /&gt;
			//$app = JFactory::getApplication();&lt;br /&gt;
			//$app-&amp;gt;enqueueMessage($e-&amp;gt;getMessage(), &#039;error&#039;);&lt;br /&gt;
&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $result;&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the brief comments in the text about what we are doing here. Important security issue: use $db-&amp;amp;gt;quote(&#039;field_value&#039;) to avoid so called &amp;quot;sql-injections&amp;quot;. Be very careful when you build sql queries. We can&#039;t describe the details to Joomla! sql queries within this tutorial. More in [http://docs.joomla.org/Accessing_the_database_using_JDatabase Accessing the database using JDatabase]&lt;br /&gt;
&lt;br /&gt;
As this is a module we don&#039;t show errormessages to the user. If there are errors the page will still be ok.&lt;br /&gt;
&lt;br /&gt;
Copy the code to your helper.php replacing the method ( = function ) getData.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The helper file is loaded and run from mod_yourmodule.php. Open it and add the following between defined(... and require.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.php - Load helper class ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    // Include the helper file that provide the data&lt;br /&gt;
   require_once __DIR__ . &#039;/helper.php&#039;;&lt;br /&gt;
&lt;br /&gt;
   //the class suffix from parameter&lt;br /&gt;
   $moduleclass_sfx = htmlspecialchars($params-&amp;gt;get(&#039;moduleclass_sfx&#039;));&lt;br /&gt;
 &lt;br /&gt;
  if ( !$article = ModYourmoduleHelper::getData($params))&lt;br /&gt;
   {&lt;br /&gt;
      //if error or article not found skip this module&lt;br /&gt;
      return false;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   //uncomment this line to see the available fields&lt;br /&gt;
   //var_dump($article);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the same time we get the class suffix from the parameter. Explained below.&lt;br /&gt;
Now that you have the article data, we will change the output file to show it. Remember? /tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
==== default.php - Show article ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source type=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After defined(... and the php closing tab we change the html. We use embedded php code to echo the title and the introtext. We add a module specific class $moduleclass sfx to the div tag. $moduleclass sfx is the class suffix the user can add in the Module Manager -&amp;amp;gt; tab Advanced. This can be used for Css styling if multiple instances of the same module are enabled. e.g. you can test to reuse your module by choosing another article. We will style them in the next step.&lt;br /&gt;
&lt;br /&gt;
=== Css styling ===&lt;br /&gt;
Best practice on a website is to &#039;&#039;&#039;try&#039;&#039;&#039; to keep all css styling in one file. As you don&#039;t know if the users template shows your module as designed you have to include a css file. Not really for what we have above but in a tutorial we do as if.&lt;br /&gt;
&lt;br /&gt;
We will not only prepare for loading css but also for images and javascript. Best practice is to store those files in subfolders of the Joomla media folder. Please don&#039;t ask why this folder was named media.&lt;br /&gt;
&lt;br /&gt;
Create folder path/to/your/joomla/media/mod_yourmodule. In the folder where you unpacked the tutorial zip file you&#039;ll find a media folder. Open this and copy all three subfolders to the new folder in your web folder. It should result in something like this &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/logs&lt;br /&gt;
/media&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /css                   *new directory*&lt;br /&gt;
      yourmodule.css       *new file*&lt;br /&gt;
    /images                *new directory*&lt;br /&gt;
      doc.png              *new file*&lt;br /&gt;
      yourmodule-logo.png  *new file*&lt;br /&gt;
    /js                    *new directory*&lt;br /&gt;
      yourmodule.js        *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/modules&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Did you use your module name?&lt;br /&gt;
&lt;br /&gt;
=== Add Css file  ===&lt;br /&gt;
&lt;br /&gt;
We include the module specific css file to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
==== default.php - Include Css file and image ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;yourmodule&amp;lt;?php echo $moduleclass_sfx ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div class=&amp;quot;row text-center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;?php echo JHtml::image(&#039;mod_yourmodule/yourmodule-logo.png&#039;, &#039;Yourmodule logo&#039;, &#039;&#039;, true, false );?&amp;gt;&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;h4&amp;gt;&amp;lt;?php echo $article-&amp;gt;title; ?&amp;gt;&amp;lt;/h4&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;div&amp;gt;&amp;lt;?php echo $article-&amp;gt;introtext; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this code added yourmodule.css will be loaded from the path media/mod_yourmodule/css/&lt;br /&gt;
Be aware of the missing /css/ ! This is added by Joomla. The image will be loaded from the path media/mod_yourmodule/images/.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s test that the css is working by adding a few lines to the yourmodule.css file. Open it with the editor and add e.g. those lines that change text color. Do we have to mention the module name?&lt;br /&gt;
&lt;br /&gt;
==== yourmodule.css ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
.yourmodule h4{&lt;br /&gt;
	color: #08c;&lt;br /&gt;
}&lt;br /&gt;
.yourmodule p {&lt;br /&gt;
	color: #005580;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On your frontend page the colors should have changed and an image added. Have a look! Be aware that your browser may have cached the css.&lt;br /&gt;
&lt;br /&gt;
=== Update the xml and the zip file  ===&lt;br /&gt;
&lt;br /&gt;
Now we have to add the new files to the xml file and create an updated installation zip file.&lt;br /&gt;
&lt;br /&gt;
Add the helper.php and the special media tag to the xml file.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add helper.php ====&lt;br /&gt;
&lt;br /&gt;
Add helper.php to the files tag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;files&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;helper.php&amp;lt;/filename&amp;gt; &lt;br /&gt;
		&amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Add media folder ====&lt;br /&gt;
&lt;br /&gt;
Add the media tag between files and languages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
	&amp;lt;media destination=&amp;quot;mod_yourmodule&amp;quot; folder=&amp;quot;media&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;css&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;images&amp;lt;/folder&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;js&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/media&amp;gt;&lt;br /&gt;
	&amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== Create the installation file ===&lt;br /&gt;
&lt;br /&gt;
Now you copy &#039;&#039;&#039;all&#039;&#039;&#039; module files from the server to the path &#039;somewhere&#039;/j_module_tutorial/new_module as in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
Create a new folder &#039;media&#039; and copy the three folders from media/mod_yourmodule.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  .../new_module&lt;br /&gt;
      /langs&lt;br /&gt;
        en-GB.mod_yourmodule.ini&lt;br /&gt;
        en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        anyother-language.mod_yourmodule.in&lt;br /&gt;
        anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /language&lt;br /&gt;
        /en-GB&lt;br /&gt;
          en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
        /anyother-language&lt;br /&gt;
          anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
      /media&lt;br /&gt;
        /css&lt;br /&gt;
          yourmodule.css&lt;br /&gt;
        /images&lt;br /&gt;
          doc.png&lt;br /&gt;
          yourmodule-logo.png&lt;br /&gt;
        /js&lt;br /&gt;
          yourmodule.js&lt;br /&gt;
      /tmpl&lt;br /&gt;
        default.php&lt;br /&gt;
      mod_yourmodule.php&lt;br /&gt;
      mod_yourmodule.xml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the compressed installation zip file as described in the &#039;Installation package&#039; part of this tutorial.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this tutorial. Below we describe an alternative for data retrieval.&lt;br /&gt;
&lt;br /&gt;
=== Use a component for data retrieval ===&lt;br /&gt;
&lt;br /&gt;
Below is an alternative to using direct sql. You can use the methods provided by a component to retrieve the data. If you develop your own component, you can prepare methods for reuse, otherwise you can try to find a method in a components models to retrieve the data you want. Here we reuse the getItem method of the content component ( articles ). In this case you get all article data returned so be a little aware of momory usage. If you want to test it, you only have to replace the getData method in helper.php&lt;br /&gt;
&lt;br /&gt;
==== helper.php Use of component ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
   	public static function getData($params)&lt;br /&gt;
	{&lt;br /&gt;
   		//get article id from module parameter&lt;br /&gt;
		$id  = $params-&amp;gt;get(&#039;article_id&#039;, 0);&lt;br /&gt;
		if ( !$id )&lt;br /&gt;
		{&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model = JModelLegacy::getInstance(&#039;Article&#039;, &#039;ContentModel&#039;, array(&#039;ignore_request&#039; =&amp;gt; true));&lt;br /&gt;
&lt;br /&gt;
		$app = JFactory::getApplication(&#039;site&#039;);&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;article.id&#039;, $id);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;list.offset&#039;, 0);&lt;br /&gt;
&lt;br /&gt;
		// Load the parameters.&lt;br /&gt;
		$params = $app-&amp;gt;getParams(&#039;com_content&#039;);&lt;br /&gt;
		$model-&amp;gt;setState(&#039;params&#039;, $params);&lt;br /&gt;
&lt;br /&gt;
		$user = JFactory::getUser();&lt;br /&gt;
&lt;br /&gt;
		if ((!$user-&amp;gt;authorise(&#039;core.edit.state&#039;, &#039;com_content&#039;)) &amp;amp;&amp;amp; (!$user-&amp;gt;authorise(&#039;core.edit&#039;, &#039;com_content&#039;)))&lt;br /&gt;
		{&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.published&#039;, 1);&lt;br /&gt;
			$model-&amp;gt;setState(&#039;filter.archived&#039;, 2);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		$model-&amp;gt;setState(&#039;filter.language&#039;, JLanguageMultilang::isEnabled());&lt;br /&gt;
  		&lt;br /&gt;
 		return $model-&amp;gt;getItem($id);;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Add javascript to the module ===&lt;br /&gt;
&lt;br /&gt;
If you want to use javascript for yourmodule, here is an example. It loads the javascript file in the media/mod_yourmodule/js path and adds a script to the header of the html document.&lt;br /&gt;
&lt;br /&gt;
Read more [[J3.x:Javascript_Frameworks|J3.x:Javascript Frameworks]]&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
$document = JFactory::getDocument();&lt;br /&gt;
$document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add this code below the line that loads the css file if you want to test it.&lt;br /&gt;
&lt;br /&gt;
* We use jQuery so we have to load it &#039;&#039;&#039;before&#039;&#039;&#039; our own modulescript. Here we load the Bootstrap framework that also includes jQuery. Use JHtml::_(&#039;jquery.framework&#039;) if you only need this.&lt;br /&gt;
* We add our scriptfile &amp;quot;relative&amp;quot; to the media folder.&lt;br /&gt;
* We add the script declaration directly to the document object. It gets added to the header in the html document.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Overrides&amp;diff=125239</id>
		<title>User:Over/Step by step to a Joomla Module - Overrides</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Overrides&amp;diff=125239"/>
		<updated>2014-09-06T04:57:26Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Overriding */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
In this step we&#039;ll use your custom module to show you how you can use the powerful Joomla! methods to override ( = change ) the output. The same possibilities are valid for all modules and components that follows the Joomla! best practice.&lt;br /&gt;
&lt;br /&gt;
=== Your site template directory ===&lt;br /&gt;
&lt;br /&gt;
As you probably know, your template is found under the templates/ folder in your Joomla! directory. The folders important for our overrides are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/templates&lt;br /&gt;
  ...&lt;br /&gt;
  /mytemplate&lt;br /&gt;
    /css&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule.css&lt;br /&gt;
      ...&lt;br /&gt;
    /html&lt;br /&gt;
      ...&lt;br /&gt;
      /com_mycomponent&lt;br /&gt;
        /view1&lt;br /&gt;
          default.php&lt;br /&gt;
        /view2&lt;br /&gt;
          default.php&lt;br /&gt;
      ...&lt;br /&gt;
      /layouts&lt;br /&gt;
        /joomla&lt;br /&gt;
          /content&lt;br /&gt;
            /info_block&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        default.php          &lt;br /&gt;
        alternative.php&lt;br /&gt;
      ...&lt;br /&gt;
    /images&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule-logo.png&lt;br /&gt;
      ...&lt;br /&gt;
    /js&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule.js&lt;br /&gt;
    ...&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The illustration above shows the paths and some of the files in your templates folder.&lt;br /&gt;
If we add files in those directories, they will be used instead of the extensions original files.&lt;br /&gt;
You can use the Template Manager to easily create overrides in the html path.  [[J3.x:How_to_use_the_Template_Manager|J3.x:How to use the Template Manager]]&lt;br /&gt;
&lt;br /&gt;
Be aware of that if you use a template including overrides, you have to find a way to protect your custom overrides when the template is updated. e.g. if you use the Beez3 template, you can create a copy of this template. See the Template Manager.&lt;br /&gt;
&lt;br /&gt;
We can also override css, images and javascripts that are loaded with the JHtml functions and &#039;relative&#039; to the media/ folder. We&#039;ll show this with the custom module you have created in this tutorial.&lt;br /&gt;
&lt;br /&gt;
=== Overriding ===&lt;br /&gt;
&lt;br /&gt;
Use the Template Manager or your file manager to copy the default.php from the /tmpl folder in your module to yourtemplate/html/mod_yourmodule/ as shown above. Open the copy with your editor and make some visual changes. Maybe you want to replace the Bootstrap classes if your template is not loading the Bootstrap Css. If you now refresh the browser page you&#039;ll see the changes.&lt;br /&gt;
&lt;br /&gt;
You can create a second override for your module with another name. e.g. alternative.php and change some visible content. Now you click New in the Module Manager and choose your module. Edit the new copy of the module and choose the second override in the Advanced tab / Alternative Layout. Enable and have a look what happend. &lt;br /&gt;
&lt;br /&gt;
You can do the same with components. As shown above, you have to add one folder per component view, where you add the output file. The name is not always default.php.  &lt;br /&gt;
&lt;br /&gt;
Copy the yourmodule.css file from media/mod_yourmodule/css to yourtemplate/css/mod_yourmodule/. Open this file and change css classes e.g. text to another color. Reload the page in the browser. Be aware of the browser cache. It can be, that you have to clear it to get the changed css loaded.&lt;br /&gt;
&lt;br /&gt;
Copy an image to yourtemplate/images/mod_yourmodule/ and rename it to the same name as used in the default.php. Reload the page and you&#039;ll see your image.&lt;br /&gt;
&lt;br /&gt;
The same possibility is valid for javascript. If they are loaded &#039;relative&#039; to the media/ path you can copy them to yourtemplate/js/mod_yourmodule/ and change them.&lt;br /&gt;
&lt;br /&gt;
As you remember we added two options to the module settings, load_css and load_js. A administrator/user may want to load css and/or javascript in other ways. If you use those parameters, the administrator can turn off the loading of your modules css and/or javacript without overriding the default.php. This is more important for components as css and javascript normaly not is loaded in overridable code.&lt;br /&gt;
&lt;br /&gt;
=== Examples - optional exclusion of css and javascript===&lt;br /&gt;
&lt;br /&gt;
==== default.php Css parameter ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
if ($params-&amp;gt;get(&#039;load_css&#039;, 1)) &lt;br /&gt;
{&lt;br /&gt;
   JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript parameter ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if ($params-&amp;gt;get(&#039;load_js&#039;, 1)) &lt;br /&gt;
{&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
$document = JFactory::getDocument();&lt;br /&gt;
$document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The html/layouts path ===&lt;br /&gt;
&lt;br /&gt;
A new possibility to Joomla! output is the reuse of parts of a view ( JLayout ).  An example is the use of the same &#039;layout&#039; in many of the different article views.  JLayout files use the layout paths. In the Joomla! root you can find a /layouts folder that include the core JLayout files. Have a look at the available ones. Third party components usually use an own folder in their backend path.&lt;br /&gt;
&lt;br /&gt;
To override those reused &#039;layouts&#039; you copy them to the corresponding path in your templates directory and make the changes. They will be automaticly loaded instead of the original one.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not likely that you can reuse a JLayout file in a module, but it is possible.&lt;br /&gt;
&lt;br /&gt;
=== Language string overrides ===&lt;br /&gt;
&lt;br /&gt;
We will not describe this type of overrides here. We only want to remind you of the possibility to change language strings in extensions that are not your own. Do not change the original files.&lt;br /&gt;
&lt;br /&gt;
Go to {{rarr|Extensions,Language Manager,Overrides}} to create overrides that change texts.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Overrides&amp;diff=125238</id>
		<title>User:Over/Step by step to a Joomla Module - Overrides</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Overrides&amp;diff=125238"/>
		<updated>2014-09-06T04:50:53Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Overriding */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
In this step we&#039;ll use your custom module to show you how you can use the powerful Joomla! methods to override ( = change ) the output. The same possibilities are valid for all modules and components that follows the Joomla! best practice.&lt;br /&gt;
&lt;br /&gt;
=== Your site template directory ===&lt;br /&gt;
&lt;br /&gt;
As you probably know, your template is found under the templates/ folder in your Joomla! directory. The folders important for our overrides are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/templates&lt;br /&gt;
  ...&lt;br /&gt;
  /mytemplate&lt;br /&gt;
    /css&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule.css&lt;br /&gt;
      ...&lt;br /&gt;
    /html&lt;br /&gt;
      ...&lt;br /&gt;
      /com_mycomponent&lt;br /&gt;
        /view1&lt;br /&gt;
          default.php&lt;br /&gt;
        /view2&lt;br /&gt;
          default.php&lt;br /&gt;
      ...&lt;br /&gt;
      /layouts&lt;br /&gt;
        /joomla&lt;br /&gt;
          /content&lt;br /&gt;
            /info_block&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        default.php          &lt;br /&gt;
        alternative.php&lt;br /&gt;
      ...&lt;br /&gt;
    /images&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule-logo.png&lt;br /&gt;
      ...&lt;br /&gt;
    /js&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule.js&lt;br /&gt;
    ...&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The illustration above shows the paths and some of the files in your templates folder.&lt;br /&gt;
If we add files in those directories, they will be used instead of the extensions original files.&lt;br /&gt;
You can use the Template Manager to easily create overrides in the html path.  [[J3.x:How_to_use_the_Template_Manager|J3.x:How to use the Template Manager]]&lt;br /&gt;
&lt;br /&gt;
Be aware of that if you use a template including overrides, you have to find a way to protect your custom overrides when the template is updated. e.g. if you use the Beez3 template, you can create a copy of this template. See the Template Manager.&lt;br /&gt;
&lt;br /&gt;
We can also override css, images and javascripts that are loaded with the JHtml functions and &#039;relative&#039; to the media/ folder. We&#039;ll show this with the custom module you have created in this tutorial.&lt;br /&gt;
&lt;br /&gt;
=== Overriding ===&lt;br /&gt;
&lt;br /&gt;
Use the Template Manager or your file manager to copy the default.php from the /tmpl folder in your module to yourtemplate/html/mod_yourmodule/ as shown above. Open the copy with your editor and make some visual changes. Maybe you want to replace the Bootstrap classes if your template is not loading the Bootstrap Css. If you now refresh the browser page you&#039;ll see the changes.&lt;br /&gt;
&lt;br /&gt;
You can create a second override for your module with another name. e.g. alternative.php and change some visible content. Now you click New in the Module Manager and choose your module. Edit the new copy of the module and choose the second override in the Advanced tab / Alternative Layout. Enable and have a look what happend. &lt;br /&gt;
&lt;br /&gt;
You can do the same with components. As shown above, you have to add one folder per component view, where you add the output file. The name is not always default.php.  &lt;br /&gt;
&lt;br /&gt;
Copy the yourmodule.css file from media/mod_yourmodule/css to yourtemplate/css/mod_yourmodule/. Open this file and change css classes e.g. text to another color. Reload the page in the browser. Be aware of the browser cache. It can be, that you have to clear it to get the changed css loaded.&lt;br /&gt;
&lt;br /&gt;
Copy an image to yourtemplate/images/mod_yourmodule/ and rename it to the same name as used in the default.php. Reload the page and you&#039;ll see your image.&lt;br /&gt;
&lt;br /&gt;
The same possibility is valid for javascript. If they are loaded &#039;relative&#039; to the media/ path you can copy them to yourtemplate/js/mod_yourmodule/ and change them.&lt;br /&gt;
&lt;br /&gt;
As you remember we added two options to the module settings, load_css and load_js. A administrator/user may want to load css and/or javascript in other ways. If you use those parameters, the administrator can turn off the loading of your modules css and/or javacript without overriding the default.php. This is more important for components as css and javascript normaly not is loaded in overridable code.&lt;br /&gt;
&lt;br /&gt;
Examples - optional exclusion of the css and javascript:&lt;br /&gt;
==== default.php Css parameter ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
if ($params-&amp;gt;get(&#039;load_css&#039;, 1)) &lt;br /&gt;
{&lt;br /&gt;
   JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript parameter ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if ($params-&amp;gt;get(&#039;load_js&#039;, 1)) &lt;br /&gt;
{&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
$document = JFactory::getDocument();&lt;br /&gt;
$document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The html/layouts path ===&lt;br /&gt;
&lt;br /&gt;
A new possibility to Joomla! output is the reuse of parts of a view ( JLayout ).  An example is the use of the same &#039;layout&#039; in many of the different article views.  JLayout files use the layout paths. In the Joomla! root you can find a /layouts folder that include the core JLayout files. Have a look at the available ones. Third party components usually use an own folder in their backend path.&lt;br /&gt;
&lt;br /&gt;
To override those reused &#039;layouts&#039; you copy them to the corresponding path in your templates directory and make the changes. They will be automaticly loaded instead of the original one.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not likely that you can reuse a JLayout file in a module, but it is possible.&lt;br /&gt;
&lt;br /&gt;
=== Language string overrides ===&lt;br /&gt;
&lt;br /&gt;
We will not describe this type of overrides here. We only want to remind you of the possibility to change language strings in extensions that are not your own. Do not change the original files.&lt;br /&gt;
&lt;br /&gt;
Go to {{rarr|Extensions,Language Manager,Overrides}} to create overrides that change texts.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Overrides&amp;diff=125237</id>
		<title>User:Over/Step by step to a Joomla Module - Overrides</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Overrides&amp;diff=125237"/>
		<updated>2014-09-06T04:47:58Z</updated>

		<summary type="html">&lt;p&gt;Over: /* default.php Css parameter */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
In this step we&#039;ll use your custom module to show you how you can use the powerful Joomla! methods to override ( = change ) the output. The same possibilities are valid for all modules and components that follows the Joomla! best practice.&lt;br /&gt;
&lt;br /&gt;
=== Your site template directory ===&lt;br /&gt;
&lt;br /&gt;
As you probably know, your template is found under the templates/ folder in your Joomla! directory. The folders important for our overrides are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/templates&lt;br /&gt;
  ...&lt;br /&gt;
  /mytemplate&lt;br /&gt;
    /css&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule.css&lt;br /&gt;
      ...&lt;br /&gt;
    /html&lt;br /&gt;
      ...&lt;br /&gt;
      /com_mycomponent&lt;br /&gt;
        /view1&lt;br /&gt;
          default.php&lt;br /&gt;
        /view2&lt;br /&gt;
          default.php&lt;br /&gt;
      ...&lt;br /&gt;
      /layouts&lt;br /&gt;
        /joomla&lt;br /&gt;
          /content&lt;br /&gt;
            /info_block&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        default.php          &lt;br /&gt;
        alternative.php&lt;br /&gt;
      ...&lt;br /&gt;
    /images&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule-logo.png&lt;br /&gt;
      ...&lt;br /&gt;
    /js&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule.js&lt;br /&gt;
    ...&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The illustration above shows the paths and some of the files in your templates folder.&lt;br /&gt;
If we add files in those directories, they will be used instead of the extensions original files.&lt;br /&gt;
You can use the Template Manager to easily create overrides in the html path.  [[J3.x:How_to_use_the_Template_Manager|J3.x:How to use the Template Manager]]&lt;br /&gt;
&lt;br /&gt;
Be aware of that if you use a template including overrides, you have to find a way to protect your custom overrides when the template is updated. e.g. if you use the Beez3 template, you can create a copy of this template. See the Template Manager.&lt;br /&gt;
&lt;br /&gt;
We can also override css, images and javascripts that are loaded with the JHtml functions and &#039;relative&#039; to the media/ folder. We&#039;ll show this with the custom module you have created in this tutorial.&lt;br /&gt;
&lt;br /&gt;
=== Overriding ===&lt;br /&gt;
&lt;br /&gt;
Use the Template Manager or your file manager to copy the default.php from the /tmpl folder in your module to yourtemplate/html/mod_yourmodule/ as shown above. Open the copy with your editor and make some visual changes. Maybe you want to replace the Bootstrap classes if your template is not loading the Bootstrap Css. If you now refresh the browser page you&#039;ll see the changes.&lt;br /&gt;
&lt;br /&gt;
You can create a second override for your module with another name. e.g. alternative.php and change some visible content. Now you click New in the Module Manager and choose your module. Edit the new copy of the module and choose the second override in the Advanced tab / Alternative Layout. Enable and have a look what happend. &lt;br /&gt;
&lt;br /&gt;
You can do the same with components. As shown above, you have to add one folder per component view, where you add the output file. The name is not always default.php.  &lt;br /&gt;
&lt;br /&gt;
Copy the yourmodule.css file from media/mod_yourmodule/css to yourtemplate/css/mod_yourmodule/. Open this file and change css classes e.g. text to another color. Reload the page in the browser. Be aware of the browser cache. It can be, that you have to clear it to get the changed css loaded.&lt;br /&gt;
&lt;br /&gt;
Copy an image to yourtemplate/images/mod_yourmodule/ and rename it to the same name as used in the default.php. Reload the page and you&#039;ll see your image.&lt;br /&gt;
&lt;br /&gt;
The same possibility is valid for javascript. If they are loaded &#039;relative&#039; to the media/ path you can copy them to yourtemplate/js/mod_yourmodule/ and change them.&lt;br /&gt;
&lt;br /&gt;
As you remember we added two options to the module settings, load_css and load_js. A administrator/user may want to load css and/or javascript in other ways. If you use those parameters, the administrator can turn off the loading of your modules css and/or javacript without overriding the default.php. This is more important for components as css and javascript normaly not is loaded in overridable code.&lt;br /&gt;
&lt;br /&gt;
Example - optional exclusion of the css:&lt;br /&gt;
==== default.php Css parameter ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
if ($params-&amp;gt;get(&#039;load_css&#039;, 1)) &lt;br /&gt;
{&lt;br /&gt;
   JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== default.php Javascript parameter ====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if ($params-&amp;gt;get(&#039;load_js&#039;, 1)) &lt;br /&gt;
{&lt;br /&gt;
   JHtml::_(&#039;bootstrap.framework&#039;);&lt;br /&gt;
&lt;br /&gt;
   JHtml::script(&#039;mod_yourmodule/yourmodule.js&#039;, false, true, false, false, false);&lt;br /&gt;
&lt;br /&gt;
$document = JFactory::getDocument();&lt;br /&gt;
$document-&amp;gt;addScriptDeclaration(&#039;jQuery( document ).ready(function()&lt;br /&gt;
		{&lt;br /&gt;
			alert(\&#039;I am an alert box!\&#039;);});&#039;&lt;br /&gt;
		);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The html/layouts path ===&lt;br /&gt;
&lt;br /&gt;
A new possibility to Joomla! output is the reuse of parts of a view ( JLayout ).  An example is the use of the same &#039;layout&#039; in many of the different article views.  JLayout files use the layout paths. In the Joomla! root you can find a /layouts folder that include the core JLayout files. Have a look at the available ones. Third party components usually use an own folder in their backend path.&lt;br /&gt;
&lt;br /&gt;
To override those reused &#039;layouts&#039; you copy them to the corresponding path in your templates directory and make the changes. They will be automaticly loaded instead of the original one.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not likely that you can reuse a JLayout file in a module, but it is possible.&lt;br /&gt;
&lt;br /&gt;
=== Language string overrides ===&lt;br /&gt;
&lt;br /&gt;
We will not describe this type of overrides here. We only want to remind you of the possibility to change language strings in extensions that are not your own. Do not change the original files.&lt;br /&gt;
&lt;br /&gt;
Go to {{rarr|Extensions,Language Manager,Overrides}} to create overrides that change texts.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125236</id>
		<title>User:Over/Step by step to a Joomla Module - Installation package</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125236"/>
		<updated>2014-09-06T04:27:59Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Alternative language files  handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to become an installable extension for any Joomla! 3.x site. e.g. after testing the functionality on your local installation you can upload and install it on your live site with a few clicks.&lt;br /&gt;
&lt;br /&gt;
=== Language files ===&lt;br /&gt;
&lt;br /&gt;
The language files hold the textstrings that are used for descriptions, field labels, field descriptions and any other static texts. You can also translate the textstrings for any language code. The default language code is en-GB, Great Britain english. In version 3 the english &amp;quot;translation&amp;quot; is in most cases loaded before any other specific language. i.e. you should always keep those files up to date.&lt;br /&gt;
&lt;br /&gt;
As in the first part of the tutorial we&#039;ll use skeleton files. In the folder, where you unzipped the downloaded file, you can find two language files, en-GB.mod_yourmodule.ini and en-GB.mod_yourmodule.sys.ini Copy those to the Joomla! en-GB language folder. path/to/joomla/language/en-GB. You can also find a language folder in the administrator/ path used for backend extensions and all plug ins.&lt;br /&gt;
&lt;br /&gt;
As always, change files named ...yourmodule... to the name you did choose. Open the first file en-GB.mod_yourmodule.ini&lt;br /&gt;
&lt;br /&gt;
===== en-GB.mod_yourmodule.ini =====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Copyright (C) 2014 Joomla Doe&lt;br /&gt;
; Translater Joomla Doe&lt;br /&gt;
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php&lt;br /&gt;
; Note : All ini files need to be saved as UTF-8 - No BOM&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE=&amp;quot;Your own module&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of my module. This one in .ini is shown when editing the module in the Module Manager. Yoü can e.g. add some tips to the confuguration and a link to a help page on your site&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the top we find some comments. As you see, you have to use ; in front of the comments. If you have friendly helpers that translate your extension, it&#039;s nice to have a line with the translators name. The use of character set UTF-8 is noted. For the language string constants you should follow the Joomla! best practice i.e. start all language constants with the extension name. &#039;&#039;&#039;The language constants have to be in upper case with _ (underscore) as divider ending with a =. The text has to be within &amp;quot; double quote.&#039;&#039;&#039; Do not use double quote within the text or you will have to find out how to use __QQ__. &#039;&#039;&#039;No line break is allowed!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
; An example with double quote&lt;br /&gt;
MOD_YOURMODULE_MY_QUOTE=&amp;quot;My value is &amp;quot;_QQ_&amp;quot;great!&amp;quot;_QQ_&amp;quot;. I like it&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is no good reference available at the time of writing. Please change this link if a better is found. [[Specification_of_language_files|Specification of language files]]&lt;br /&gt;
&lt;br /&gt;
Change the two MOD_YOURMODULE, change the first text to a &amp;quot;human&amp;quot; name of your module and change the description. Again: in one line! &#039;&#039;&#039;no line break is allowed!&#039;&#039;&#039;. If you add e.g. a link remeber &amp;quot;_QQ_&amp;quot; for double quotes. Save this file and copy the text except the description content. The second file has almost the same content at this stage. Open en-GB.mod_yourmodule.sys.ini and paste the copied text replacing the text i.e. not the description text.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of your module. This one in .sys.ini is shown when choosing a new module in the module manager and in the extension manager. Keep this shorter.&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the description and save.&lt;br /&gt;
&lt;br /&gt;
The difference between those is that the .sys.ini file is loaded in cases like module lists where no module fields are shown. We´ll see another use of the .sys.ini below.&lt;br /&gt;
&lt;br /&gt;
As promised in the first part of the tutorial, you can now see the reason for using mod_yourmodule as module name in the xml file. Go to Module Manager, click on new. You will find your module with the name from the language file. Next we will fix the description. Before you close the files copy the constant MOD_YOURMODULE_XML_DESCRIPTION.&lt;br /&gt;
&lt;br /&gt;
Open mod_yourmodule.xml from the server and find the description line. Replace the description with your copied language constant MOD_YOURMODULE_XML_DESCRIPTION.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Description ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;MOD_YOURMODULE_XML_DESCRIPTION&amp;lt;/description&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can make the same test as before in the Module Manager and you&#039;ll see that the description comes from the language files.&lt;br /&gt;
&lt;br /&gt;
=== Parameters - Options ===&lt;br /&gt;
If you choose your enabled module for edit in the Module Manager you&#039;ll se some default options under the advanced tab. Let&#039;s add some more options in the xml file and add the used language strings before we create the first installable package.&lt;br /&gt;
&lt;br /&gt;
Add the following where you find the config part. We will see more around form fields in a later tutorial part.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Config ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;config&amp;gt;&lt;br /&gt;
      &amp;lt;fields name=&amp;quot;params&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;options&amp;quot; label=&amp;quot;COM_MODULES_BASIC_FIELDSET_LABEL&amp;quot;&lt;br /&gt;
            addfieldpath=&amp;quot;/administrator/components/com_content/models/fields/modal&amp;quot;&lt;br /&gt;
	 &amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;article_id&amp;quot;&lt;br /&gt;
               type=&amp;quot;modal_article&amp;quot;&lt;br /&gt;
               default=&amp;quot;&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_DESC&amp;quot; &amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;advanced&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_css&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_js&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;layout&amp;quot;&lt;br /&gt;
               type=&amp;quot;modulelayout&amp;quot;&lt;br /&gt;
               label=&amp;quot;JFIELD_ALT_LAYOUT_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;JFIELD_ALT_MODULE_LAYOUT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;moduleclass_sfx&amp;quot;&lt;br /&gt;
               type=&amp;quot;textarea&amp;quot; rows=&amp;quot;3&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache&amp;quot;&lt;br /&gt;
               type=&amp;quot;list&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHING_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHING_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JGLOBAL_USE_GLOBAL&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;COM_MODULES_FIELD_VALUE_NOCACHING&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache_time&amp;quot;&lt;br /&gt;
               type=&amp;quot;text&amp;quot;&lt;br /&gt;
               default=&amp;quot;900&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cachemode&amp;quot;&lt;br /&gt;
               type=&amp;quot;hidden&amp;quot;&lt;br /&gt;
               default=&amp;quot;static&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;static&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
      &amp;lt;/fields&amp;gt;&lt;br /&gt;
   &amp;lt;/config&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the fieldset options we add an option field &amp;quot;article_id&amp;quot; that we will use later. This field calls a modal window where you can choose an article. Fieldset options is shown in the tab Options in the Module Manager. If you use a fieldset named basic you&#039;ll have those fields in the first tab. We also add some standard option fields to the &amp;quot;Advanced&amp;quot; tab. We do not have to add the text constants used in the Advanced part since they are standard. Remains the two strings used for the article field. Well, we added two fields in the advanced tab, load_css and load_js with language strings that need to be added. We&#039;ll come back to the use of those options later. &lt;br /&gt;
&lt;br /&gt;
Follow this link to read more about [http://docs.joomla.org/Module Joomla modules and the Modules Manager]&lt;br /&gt;
&lt;br /&gt;
=== Add strings to language file ===&lt;br /&gt;
Save the xml file and open the language file. The one without .sys.&lt;br /&gt;
&lt;br /&gt;
Add the 6 strings and save.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.ini - New strings ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_DESC=&amp;quot;Choose an article to be shown by the module.&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_LABEL=&amp;quot;Article&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_DESC=&amp;quot;You can disable the modules css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL=&amp;quot;Load Css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_DESC=&amp;quot;You can disable the modules JavaScript&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_LABEL=&amp;quot;Load JavaScript&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Final change to the xml file ===&lt;br /&gt;
&lt;br /&gt;
Before we create the first installation file we will add the language tags to the xml file below the &amp;lt;/files&amp;gt; tag.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Final ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
   &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We use a folder named langs here, because we will use the folder language for a trick. If you include other language files just add lines with the correspondent language identifier.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;large-12 panel radius&amp;quot; style=&amp;quot;background-color:#fff; border:1px solid #aaa; margin:1em 0;&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;For those of you that have some knowledge of Joomla development:&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
Do not add the /language folder to the xml file. It is autoloaded. i.e. extracted and used in the installation process by default.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the xml file.&lt;br /&gt;
&lt;br /&gt;
=== Create the compressed installation file ===&lt;br /&gt;
Now we have everything to create the first version of the installation file.&lt;br /&gt;
&lt;br /&gt;
Inside the folder you created on yor local system at the start of the tutorial &#039;somewhere&#039;/j_module_tutorial/new_module you add three sub directories. langs, language and tmpl. Now you copy the files in the other direction. From the web directory to the new one. It should look something like this ( remember - yourmodule - is a placeholder for your choosen module name ):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
.../new_module&lt;br /&gt;
     /langs&lt;br /&gt;
       en-GB.mod_yourmodule.ini&lt;br /&gt;
       en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
       anyother-language.mod_yourmodule.in&lt;br /&gt;
       anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
     /language&lt;br /&gt;
       /en-GB&lt;br /&gt;
         en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
       /anyother-language&lt;br /&gt;
         anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
     /tmpl&lt;br /&gt;
       default.php&lt;br /&gt;
     mod_yourmodule.php&lt;br /&gt;
     mod_yourmodule.xml&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a last step we&#039;ll edit the .../new_module/language/en-GB/mod_yourmodule.sys.ini to show a different message at installation/upgrade.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.sys.ini - Installation message ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;Thank you for installing / update the Your own module. This module displays an article text in a module position. To activate you go to the module manager and edit this module or create a new entry. Select the article you want to show. Please visit www.mysite.com for more information. If you like it please add a review on JED.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you edit the description text to include a &amp;quot;Thanks&amp;quot; and other informations only relevant directly after the installation / upgrade this is a trick to achieve this. Only .../new_module/langs/language-codes.mod_yourmodule.sys.ini will be copied and used after the installation.&lt;br /&gt;
&lt;br /&gt;
You can find two short descriptions of alternative handling of the language files at the end of this page.&lt;br /&gt;
&lt;br /&gt;
Now we compress the files. The Zip type is recommended as it has native support by most systems. In Windows you go to the .../new_module folder. Mark the included folders and files, right click and choose {{rarr|Send to,ZIP compressed folder}}.&lt;br /&gt;
&lt;br /&gt;
Rename the .zip file to mod_yourmodule_1_0_0.zip i.e. including the version number. You should better move this file to another folder. It is easy forgotten NOT to include it, the next time you create a zipped file.&lt;br /&gt;
&lt;br /&gt;
You made a backup before starting the tutorial? Well, only in case of ...&lt;br /&gt;
&lt;br /&gt;
First you uninstall the module to get a complete new installation {{rarr|Extensions,Manager,Manage}} Look up the module. Filter e.g. Location = Site, Type=Module and/or name.&lt;br /&gt;
&lt;br /&gt;
When the module is uninstalled you go to Install, browse to your installation zip file and click the Upload &amp;amp;amp; Install button. You&#039;ll see the description you edited as installation message. Go to the Module Manager. This time you should find an entry in the Module list. Choose this and enable it, as you did after the Discover in the first part of the tutorial. You can also see that the description is the one from your .ini file. To check the description from .sys.ini click on NEW module. This is not the one you saw directly after the installation.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this part of the module tutorial. The next part will show you how to retrieve data and add some Css styling to your module.&lt;br /&gt;
&lt;br /&gt;
=== Alternative language files  handling ===&lt;br /&gt;
&lt;br /&gt;
For both alternatives you have to add all language files to subfolders in the /language folder. Be aware that the folder name is mandatory! &lt;br /&gt;
&lt;br /&gt;
You can use the language files from the /langs folder in the example above. Do not add a long description to the .sys.ini files, as it will be used for the module lists. Of course you have to remove the /langs folder, if you want to test by changing the example above.&lt;br /&gt;
&lt;br /&gt;
Resulting folder:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/language&lt;br /&gt;
  /en-GB&lt;br /&gt;
    en-GB.mod_yourmodule.ini&lt;br /&gt;
    en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
  /anyother-language&lt;br /&gt;
    anyother-language.mod_yourmodule.ini&lt;br /&gt;
    anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== 1. Easiest way  ====&lt;br /&gt;
&lt;br /&gt;
Add a folder tag to the files area in the xml file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;folder&amp;gt;language&amp;lt;/folder&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The folder will be stored in the extensions folder and no files in the core language folder.&lt;br /&gt;
ALL files are copied, not only the ones for installed languages.&lt;br /&gt;
&lt;br /&gt;
==== 2. Traditional way  ====&lt;br /&gt;
&lt;br /&gt;
Add all single language files to the languages tag in the xml file. Be aware of the extra folder name required (= language tag).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;language&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt; &lt;br /&gt;
  &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files are saved to the core language folder in the traditional way.&lt;br /&gt;
Only the files for installed languages are copied.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125235</id>
		<title>User:Over/Step by step to a Joomla Module - Installation package</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125235"/>
		<updated>2014-09-06T04:20:34Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Create the compressed installation file */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to become an installable extension for any Joomla! 3.x site. e.g. after testing the functionality on your local installation you can upload and install it on your live site with a few clicks.&lt;br /&gt;
&lt;br /&gt;
=== Language files ===&lt;br /&gt;
&lt;br /&gt;
The language files hold the textstrings that are used for descriptions, field labels, field descriptions and any other static texts. You can also translate the textstrings for any language code. The default language code is en-GB, Great Britain english. In version 3 the english &amp;quot;translation&amp;quot; is in most cases loaded before any other specific language. i.e. you should always keep those files up to date.&lt;br /&gt;
&lt;br /&gt;
As in the first part of the tutorial we&#039;ll use skeleton files. In the folder, where you unzipped the downloaded file, you can find two language files, en-GB.mod_yourmodule.ini and en-GB.mod_yourmodule.sys.ini Copy those to the Joomla! en-GB language folder. path/to/joomla/language/en-GB. You can also find a language folder in the administrator/ path used for backend extensions and all plug ins.&lt;br /&gt;
&lt;br /&gt;
As always, change files named ...yourmodule... to the name you did choose. Open the first file en-GB.mod_yourmodule.ini&lt;br /&gt;
&lt;br /&gt;
===== en-GB.mod_yourmodule.ini =====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Copyright (C) 2014 Joomla Doe&lt;br /&gt;
; Translater Joomla Doe&lt;br /&gt;
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php&lt;br /&gt;
; Note : All ini files need to be saved as UTF-8 - No BOM&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE=&amp;quot;Your own module&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of my module. This one in .ini is shown when editing the module in the Module Manager. Yoü can e.g. add some tips to the confuguration and a link to a help page on your site&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the top we find some comments. As you see, you have to use ; in front of the comments. If you have friendly helpers that translate your extension, it&#039;s nice to have a line with the translators name. The use of character set UTF-8 is noted. For the language string constants you should follow the Joomla! best practice i.e. start all language constants with the extension name. &#039;&#039;&#039;The language constants have to be in upper case with _ (underscore) as divider ending with a =. The text has to be within &amp;quot; double quote.&#039;&#039;&#039; Do not use double quote within the text or you will have to find out how to use __QQ__. &#039;&#039;&#039;No line break is allowed!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
; An example with double quote&lt;br /&gt;
MOD_YOURMODULE_MY_QUOTE=&amp;quot;My value is &amp;quot;_QQ_&amp;quot;great!&amp;quot;_QQ_&amp;quot;. I like it&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is no good reference available at the time of writing. Please change this link if a better is found. [[Specification_of_language_files|Specification of language files]]&lt;br /&gt;
&lt;br /&gt;
Change the two MOD_YOURMODULE, change the first text to a &amp;quot;human&amp;quot; name of your module and change the description. Again: in one line! &#039;&#039;&#039;no line break is allowed!&#039;&#039;&#039;. If you add e.g. a link remeber &amp;quot;_QQ_&amp;quot; for double quotes. Save this file and copy the text except the description content. The second file has almost the same content at this stage. Open en-GB.mod_yourmodule.sys.ini and paste the copied text replacing the text i.e. not the description text.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of your module. This one in .sys.ini is shown when choosing a new module in the module manager and in the extension manager. Keep this shorter.&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the description and save.&lt;br /&gt;
&lt;br /&gt;
The difference between those is that the .sys.ini file is loaded in cases like module lists where no module fields are shown. We´ll see another use of the .sys.ini below.&lt;br /&gt;
&lt;br /&gt;
As promised in the first part of the tutorial, you can now see the reason for using mod_yourmodule as module name in the xml file. Go to Module Manager, click on new. You will find your module with the name from the language file. Next we will fix the description. Before you close the files copy the constant MOD_YOURMODULE_XML_DESCRIPTION.&lt;br /&gt;
&lt;br /&gt;
Open mod_yourmodule.xml from the server and find the description line. Replace the description with your copied language constant MOD_YOURMODULE_XML_DESCRIPTION.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Description ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;MOD_YOURMODULE_XML_DESCRIPTION&amp;lt;/description&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can make the same test as before in the Module Manager and you&#039;ll see that the description comes from the language files.&lt;br /&gt;
&lt;br /&gt;
=== Parameters - Options ===&lt;br /&gt;
If you choose your enabled module for edit in the Module Manager you&#039;ll se some default options under the advanced tab. Let&#039;s add some more options in the xml file and add the used language strings before we create the first installable package.&lt;br /&gt;
&lt;br /&gt;
Add the following where you find the config part. We will see more around form fields in a later tutorial part.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Config ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;config&amp;gt;&lt;br /&gt;
      &amp;lt;fields name=&amp;quot;params&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;options&amp;quot; label=&amp;quot;COM_MODULES_BASIC_FIELDSET_LABEL&amp;quot;&lt;br /&gt;
            addfieldpath=&amp;quot;/administrator/components/com_content/models/fields/modal&amp;quot;&lt;br /&gt;
	 &amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;article_id&amp;quot;&lt;br /&gt;
               type=&amp;quot;modal_article&amp;quot;&lt;br /&gt;
               default=&amp;quot;&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_DESC&amp;quot; &amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;advanced&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_css&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_js&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;layout&amp;quot;&lt;br /&gt;
               type=&amp;quot;modulelayout&amp;quot;&lt;br /&gt;
               label=&amp;quot;JFIELD_ALT_LAYOUT_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;JFIELD_ALT_MODULE_LAYOUT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;moduleclass_sfx&amp;quot;&lt;br /&gt;
               type=&amp;quot;textarea&amp;quot; rows=&amp;quot;3&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache&amp;quot;&lt;br /&gt;
               type=&amp;quot;list&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHING_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHING_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JGLOBAL_USE_GLOBAL&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;COM_MODULES_FIELD_VALUE_NOCACHING&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache_time&amp;quot;&lt;br /&gt;
               type=&amp;quot;text&amp;quot;&lt;br /&gt;
               default=&amp;quot;900&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cachemode&amp;quot;&lt;br /&gt;
               type=&amp;quot;hidden&amp;quot;&lt;br /&gt;
               default=&amp;quot;static&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;static&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
      &amp;lt;/fields&amp;gt;&lt;br /&gt;
   &amp;lt;/config&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the fieldset options we add an option field &amp;quot;article_id&amp;quot; that we will use later. This field calls a modal window where you can choose an article. Fieldset options is shown in the tab Options in the Module Manager. If you use a fieldset named basic you&#039;ll have those fields in the first tab. We also add some standard option fields to the &amp;quot;Advanced&amp;quot; tab. We do not have to add the text constants used in the Advanced part since they are standard. Remains the two strings used for the article field. Well, we added two fields in the advanced tab, load_css and load_js with language strings that need to be added. We&#039;ll come back to the use of those options later. &lt;br /&gt;
&lt;br /&gt;
Follow this link to read more about [http://docs.joomla.org/Module Joomla modules and the Modules Manager]&lt;br /&gt;
&lt;br /&gt;
=== Add strings to language file ===&lt;br /&gt;
Save the xml file and open the language file. The one without .sys.&lt;br /&gt;
&lt;br /&gt;
Add the 6 strings and save.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.ini - New strings ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_DESC=&amp;quot;Choose an article to be shown by the module.&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_LABEL=&amp;quot;Article&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_DESC=&amp;quot;You can disable the modules css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL=&amp;quot;Load Css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_DESC=&amp;quot;You can disable the modules JavaScript&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_LABEL=&amp;quot;Load JavaScript&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Final change to the xml file ===&lt;br /&gt;
&lt;br /&gt;
Before we create the first installation file we will add the language tags to the xml file below the &amp;lt;/files&amp;gt; tag.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Final ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
   &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We use a folder named langs here, because we will use the folder language for a trick. If you include other language files just add lines with the correspondent language identifier.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;large-12 panel radius&amp;quot; style=&amp;quot;background-color:#fff; border:1px solid #aaa; margin:1em 0;&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;For those of you that have some knowledge of Joomla development:&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
Do not add the /language folder to the xml file. It is autoloaded. i.e. extracted and used in the installation process by default.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the xml file.&lt;br /&gt;
&lt;br /&gt;
=== Create the compressed installation file ===&lt;br /&gt;
Now we have everything to create the first version of the installation file.&lt;br /&gt;
&lt;br /&gt;
Inside the folder you created on yor local system at the start of the tutorial &#039;somewhere&#039;/j_module_tutorial/new_module you add three sub directories. langs, language and tmpl. Now you copy the files in the other direction. From the web directory to the new one. It should look something like this ( remember - yourmodule - is a placeholder for your choosen module name ):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
.../new_module&lt;br /&gt;
     /langs&lt;br /&gt;
       en-GB.mod_yourmodule.ini&lt;br /&gt;
       en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
       anyother-language.mod_yourmodule.in&lt;br /&gt;
       anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
     /language&lt;br /&gt;
       /en-GB&lt;br /&gt;
         en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
       /anyother-language&lt;br /&gt;
         anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
     /tmpl&lt;br /&gt;
       default.php&lt;br /&gt;
     mod_yourmodule.php&lt;br /&gt;
     mod_yourmodule.xml&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a last step we&#039;ll edit the .../new_module/language/en-GB/mod_yourmodule.sys.ini to show a different message at installation/upgrade.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.sys.ini - Installation message ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;Thank you for installing / update the Your own module. This module displays an article text in a module position. To activate you go to the module manager and edit this module or create a new entry. Select the article you want to show. Please visit www.mysite.com for more information. If you like it please add a review on JED.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you edit the description text to include a &amp;quot;Thanks&amp;quot; and other informations only relevant directly after the installation / upgrade this is a trick to achieve this. Only .../new_module/langs/language-codes.mod_yourmodule.sys.ini will be copied and used after the installation.&lt;br /&gt;
&lt;br /&gt;
You can find two short descriptions of alternative handling of the language files at the end of this page.&lt;br /&gt;
&lt;br /&gt;
Now we compress the files. The Zip type is recommended as it has native support by most systems. In Windows you go to the .../new_module folder. Mark the included folders and files, right click and choose {{rarr|Send to,ZIP compressed folder}}.&lt;br /&gt;
&lt;br /&gt;
Rename the .zip file to mod_yourmodule_1_0_0.zip i.e. including the version number. You should better move this file to another folder. It is easy forgotten NOT to include it, the next time you create a zipped file.&lt;br /&gt;
&lt;br /&gt;
You made a backup before starting the tutorial? Well, only in case of ...&lt;br /&gt;
&lt;br /&gt;
First you uninstall the module to get a complete new installation {{rarr|Extensions,Manager,Manage}} Look up the module. Filter e.g. Location = Site, Type=Module and/or name.&lt;br /&gt;
&lt;br /&gt;
When the module is uninstalled you go to Install, browse to your installation zip file and click the Upload &amp;amp;amp; Install button. You&#039;ll see the description you edited as installation message. Go to the Module Manager. This time you should find an entry in the Module list. Choose this and enable it, as you did after the Discover in the first part of the tutorial. You can also see that the description is the one from your .ini file. To check the description from .sys.ini click on NEW module. This is not the one you saw directly after the installation.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this part of the module tutorial. The next part will show you how to retrieve data and add some Css styling to your module.&lt;br /&gt;
&lt;br /&gt;
=== Alternative language files  handling ===&lt;br /&gt;
&lt;br /&gt;
For both alternatives you have to add all language files to subfolders in the /language folder. Be aware that the folder name is mandatory! &lt;br /&gt;
&lt;br /&gt;
You can use the language files from the /langs folder in the example above. Do not add a long description to the .sys.ini files, as it will be used for the module lists. Of course you have to remove the /langs folder, if you want to test by changing the example above.&lt;br /&gt;
&lt;br /&gt;
Resulting folder:&lt;br /&gt;
&lt;br /&gt;
* /language&lt;br /&gt;
** /en-GB&lt;br /&gt;
*** en-GB.mod_yourmodule.ini&lt;br /&gt;
*** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
** /anyother-language&lt;br /&gt;
*** anyother-language.mod_yourmodule.ini&lt;br /&gt;
*** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
&lt;br /&gt;
==== 1. Easiest way  ====&lt;br /&gt;
&lt;br /&gt;
Add a folder tag to the files area in the xml file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;folder&amp;gt;language&amp;lt;/folder&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The folder will be stored in the extensions folder and no files in the core language folder.&lt;br /&gt;
ALL files are copied, not only the ones for installed languages.&lt;br /&gt;
&lt;br /&gt;
==== 2. Traditional way  ====&lt;br /&gt;
&lt;br /&gt;
Add all single language files to the languages tag in the xml file. Be aware of the extra folder name required (= language tag).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;language&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt; &lt;br /&gt;
  &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files are saved to the core language folder in the traditional way.&lt;br /&gt;
Only the files for installed languages are copied.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Basic&amp;diff=125234</id>
		<title>User:Over/Step by step to a Joomla Module - Basic</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Basic&amp;diff=125234"/>
		<updated>2014-09-06T04:04:51Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Install and enable the module */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you&lt;br /&gt;
&lt;br /&gt;
* have some interest in understanding the Joomla! Cms a little under the hood.&lt;br /&gt;
* are new to Joomla and want to be able to modify your site more than per option settings.&lt;br /&gt;
* have knowledge in web development but not with the Joomla! Cms&lt;br /&gt;
&lt;br /&gt;
this is something for you.&lt;br /&gt;
&lt;br /&gt;
{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
The first step will show you how to get your own custom module running in just a few minutes. Well, you have of course to subtract the time it takes to read and follow this text from the total time.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
Before we start, some words about the requirements. You need access to a system with version 3.x of Joomla! installed. This with a web server - PHP, MySQL and Apache ( or a Microsoft IIS server ). A very good idea is to install a server on your local system. It will allow you to test any future changes, before you implement it on your live server. You can find documentation and hints how to do that by searching the www for Joomla and WAMP, LAMP, XAMPP, MAMP ...&lt;br /&gt;
&lt;br /&gt;
Example, without preference, from the Joomla! Community Magazine [http://magazine.joomla.org/issues/issue-mar-2013/item/1110-free-e-book-%E2%80%93-introducing-joomla-30-made-easy Installing Joomla 3.0 on local host using XAMPP] There are many users that find MAMP for Mac or WAMP for Windows easier to install and run.&lt;br /&gt;
&lt;br /&gt;
For the coding you need an editor. If you plan to develop in a larger scale you probably want to use an IDE, integrated development enviroment, or already have one. You can find information on alternatives elsewhere. If you only want to follow this tutorial and later make some minor changes (overrides) you can use a simpler editor. Search one for your local system. For Windows is Notepad++ an example. IMPORTANT! The Editor must be able to save the files with Unix type end of line (EOL) and character set UTF-8 w/o BOM (without byte order mark). You have to set this in the settings of the editor you use. This is a Joomla! requirement and may leave you with some surprises, if you don&#039;t follow it.&lt;br /&gt;
&lt;br /&gt;
[[Setting_up_your_workstation_for_Joomla_development|More technical documentation]]&lt;br /&gt;
&lt;br /&gt;
=== Prepare files ===&lt;br /&gt;
&lt;br /&gt;
OK! If you now have got it all together, let&#039;s start. There are some zipped files available. We&#039;ll use them as skeletons for the code we create. Download [http://github.com/schnuti/module-tutorial/zipball/master/ !!! replace with Joomla download !!!] to a new folder you can easily find. e.g. &#039;somewhere&#039;/j3_module_tutorial. Unzip it. As we are in the mood of creating folders add another subfolder e.g. &#039;somewhere&#039;/j3_module_tutorial/new_module. We will use that in a next tutorial to create the installation file for your module.&lt;br /&gt;
&lt;br /&gt;
Something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/&#039;somewhere&#039;&lt;br /&gt;
  /j3_module_tutorial        *new directory*&lt;br /&gt;
    /&#039;unpacked zip&#039;      &lt;br /&gt;
      ...                    *the files*&lt;br /&gt;
  /new_module                *new directory*&lt;br /&gt;
    ...                      *your own module files*&lt;br /&gt;
  downloaded.zip          &lt;br /&gt;
  mod_yourmodule_x_y_z.zip   *created during tutorial*&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should choose another name for your custom module. Development in a FOSS enviroment, free open source software, is not much about entering code. You use available code, copy/paste and make some modifications. At the end of this tutorial you&#039;ll have your own module, that you can use as &amp;quot;framework&amp;quot; for your next &amp;quot;module idea&amp;quot;. You only have to replace the name you gave the module with a new name.  We&#039;ll use &amp;quot;Yourmodule&amp;quot; throughout the tutorial. Always substitute this with your chosen name! Most of the times you have to use lower case as now with the directories and filenames. &lt;br /&gt;
&lt;br /&gt;
Look up the Joomla! root directory on your test system. It depends on your server and Joomla! installation. For Wamp it might be c:\wamp\www\joomla. For XAMPP c:\xampp\htdocs\joomla. Here you&#039;ll find a modules directory where you create a subdirectory mod_yourmodule. Don&#039;t forget to use your own name! We also need a mod_yourmodule/tmpl directory.&lt;br /&gt;
&lt;br /&gt;
In this step we&#039;ll only use 3 files. mod_yourmodule.xml - the so called manifest file that controls the installation and in the module case holds any configuration options, mod_yourmodule.php is the start up file / entry point. default.php holds the code for output. The latter can be named otherwise and is also called template or layout. Somewhat confusing as template and layout is used also in other contexts.&lt;br /&gt;
&lt;br /&gt;
Now you copy mod_yourmodule.xml and mod_yourmodule.php to your path/to/joomla/modules/mod_yourmodule directory. Rename! You copy default.php to path/to/joomla/modules/mod_yourmodule/tmpl.&lt;br /&gt;
&lt;br /&gt;
After you created the 2 new directories and copied the 3 new files your Joomla path should look like below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/media&lt;br /&gt;
/modules&lt;br /&gt;
  ...&lt;br /&gt;
  /mod_yourmodule          *new directory*&lt;br /&gt;
    /tmpl                  *new directory*&lt;br /&gt;
      default.php          *new file*&lt;br /&gt;
    mod_yourmodule.php     *new file*&lt;br /&gt;
    mod_yourmodule.xml     *new file*&lt;br /&gt;
  ...&lt;br /&gt;
/plugins&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The modules xml file ===&lt;br /&gt;
&lt;br /&gt;
Open mod_yourmodule.xml with your editor. We&#039;ll have a look at what we have there and make some modifications.&lt;br /&gt;
&lt;br /&gt;
More information about [[Manifest_files|Manifest files]]. We will come back to this file more than once to add more tags and definitions.&lt;br /&gt;
&lt;br /&gt;
===== mod_yourmodule.xml =====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;module&amp;quot; version=&amp;quot;3.3.0&amp;quot; client=&amp;quot;site&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;name&amp;gt;mod_yourmodule&amp;lt;/name&amp;gt;&lt;br /&gt;
    &amp;lt;version&amp;gt;1.0.0&amp;lt;/version&amp;gt;&lt;br /&gt;
	&amp;lt;creationDate&amp;gt;August 2014&amp;lt;/creationDate&amp;gt;&lt;br /&gt;
    &amp;lt;author&amp;gt;Joomla Doe&amp;lt;/author&amp;gt;&lt;br /&gt;
	&amp;lt;authorUrl&amp;gt;www.yourmodule.org&amp;lt;/authorUrl&amp;gt;&lt;br /&gt;
 	&amp;lt;authorEmail&amp;gt;joomla.doe@yourmodule.org&amp;lt;/authorEmail&amp;gt;&lt;br /&gt;
	&amp;lt;copyright&amp;gt;Copyright (C) 2014 Joomla Doe&amp;lt;/copyright&amp;gt;&lt;br /&gt;
	&amp;lt;license&amp;gt;GNU General Public License version 2 or later; see LICENSE.txt&amp;lt;/license&amp;gt;&lt;br /&gt;
    &amp;lt;description&amp;gt;Your own first custom module.&amp;lt;/description&amp;gt;&lt;br /&gt;
    &amp;lt;files&amp;gt;&lt;br /&gt;
        &amp;lt;filename&amp;gt;mod_yourmodule.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
        &amp;lt;filename module=&amp;quot;mod_yourmodule&amp;quot;&amp;gt;mod_yourmodule.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
        &amp;lt;folder&amp;gt;tmpl&amp;lt;/folder&amp;gt;&lt;br /&gt;
    &amp;lt;/files&amp;gt;&lt;br /&gt;
    &amp;lt;config&amp;gt;&lt;br /&gt;
    &amp;lt;/config&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The content of the xml file is almost self explaining. We define the extension as a module for Joomla! versions 3.3.0 and above. 3.3.3 is the latest version at the time of creating the tutorial Upgrade means that we leave to the installer program to decide, if it is a new installation or an update/upgrade. The name, the version and the date of the extension. Be extra careful with the module name. Any errors will stop the installation. We use mod_yourmodule as name and will come back to the reason in a later part. Information about the author with contact data. Copyright and license. If the module will be for your own private use only, you don&#039;t need all of it. It is however a good practice to include it.&lt;br /&gt;
&lt;br /&gt;
In the description you obviously explain what the module is supposed to do.&lt;br /&gt;
&lt;br /&gt;
In the files part you define what files and folders are included in your module. folder has the effect that all included files will be copied from your packed installation file to that directory (=folder). You don&#039;t have to include mod_yourmodule.xml here as it always will be copied.&lt;br /&gt;
&lt;br /&gt;
Comment: We did not include any index.html files. These were used to prevent users to attempt to list the content by pointing their browser to these folders. Joomla! has dropped this requirement. Acces is blocked by your .htaccess / web.config file if properly set up. The default of those files include the needed settings.&lt;br /&gt;
&lt;br /&gt;
We&#039;ll come back to &amp;amp;lt;config&amp;amp;gt; when we extend the functionality. It stays empty for now.&lt;br /&gt;
&lt;br /&gt;
Edit this file and replace the data with your own name/modulename.&lt;br /&gt;
&lt;br /&gt;
Save and close mod_yourmodule.xml&lt;br /&gt;
&lt;br /&gt;
=== The start up file ===&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll have a look at the entry point file mod_yourmodule.php.&lt;br /&gt;
&lt;br /&gt;
===== mod_yourmodule.php =====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
&lt;br /&gt;
require JModuleHelper::getLayoutPath(&#039;mod_yourmodule&#039;, $params-&amp;gt;get(&#039;layout&#039;, &#039;default&#039;));&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Not more than this is needed for the most basic module we develop in this first tutorial part.&lt;br /&gt;
&lt;br /&gt;
You tell the system that this is php code and write a comment. You can find example comments in any Joomla! core php file or any 3.d party extension. You can add more information if you like but do not overdo. If you use functionality from another developers in the code it&#039;s a nice practice to mention that. Something like : this is a fork of mod_yourmodule by Joomla Doe. &lt;br /&gt;
&lt;br /&gt;
The line defined(... has to be included! It prevents users from running this php code from outside of Joomla!.&lt;br /&gt;
&lt;br /&gt;
The last line calls the default.php file that includes the output commands ( name without php ending ). You can see that the confusing word layout is used. Here it means a file in the tmpl folder.&lt;br /&gt;
&lt;br /&gt;
{{Tip|Do not add a php closing tag &#039; ?&amp;gt;&#039; at the end of a php file. Add an empty line at the end of files.}}&lt;br /&gt;
&lt;br /&gt;
Edit the module name and save. Do not close it if your editor allows to hold two or more files open.&lt;br /&gt;
&lt;br /&gt;
If you want to know more about Joomla! coding standards: [http://joomla.github.io/coding-standards/ joomla coding-standards] Contibutions to Joomla! core development must follow those standards.&lt;br /&gt;
&lt;br /&gt;
More for advanced developers: [[Joomla_CodeSniffer|Joomla CodeSniffer]] and [https://github.com/joomla/coding-standards/tree/master/IDE joomla/ coding-standards - IDE]&lt;br /&gt;
&lt;br /&gt;
=== The output/template/layout file ===&lt;br /&gt;
&lt;br /&gt;
The last file to edit before we enable the module for the frontend pages is the default.php&lt;br /&gt;
&lt;br /&gt;
===== default.php =====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * package     Your module&lt;br /&gt;
 * copyright   Copyright (C) 2014 Joomla Doe&lt;br /&gt;
 * license     GNU General Public License version 2 or later; see LICENSE.txt&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die( &#039;Restricted access&#039; );&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;h3&amp;gt;From your first module&amp;lt;/h3&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;This is the content&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy the comments part - that you changed - from the former php file and paste it here, replacing the comment. After the obligatory defined(... line we close the php part with ?&amp;gt;. The rest is at your disposal. Use the knowledge you have of html code to show text on the frontpage. Alternatively you can write a very short article in the Joomla! backend, toggle the editor and copy the source code to the php file. If you do, save the article and note the article. We&#039;ll use an article as source in a later step.&lt;br /&gt;
&lt;br /&gt;
After saving the file we are ready to enable your custom module on the frontend.&lt;br /&gt;
&lt;br /&gt;
=== Install and enable the module ===&lt;br /&gt;
&lt;br /&gt;
{{Tip|Before you proceed it might be a good idea to backup your test site. Well, only in case of ...}}&lt;br /&gt;
The most simple way to backup your local server is to copy the whole web directory. It includes both your local site and the database. See path examples above. &lt;br /&gt;
&lt;br /&gt;
We do not need to create a compressed installation file (.zip) to install an extension. We&#039;ll use the Discover method.&lt;br /&gt;
&lt;br /&gt;
Go to {{rarr|Extensions,Extension Manager,Click on Discover}}, in the Extension Manager:Discover menu you click on the Discover button&lt;br /&gt;
&lt;br /&gt;
Mark your module in the list and click on the Install button. If everything went well, you&#039;ll get a message that tells you that the module was installed.&lt;br /&gt;
&lt;br /&gt;
At last you enable the module in the Module Manager. Click on New and find it in the the list. As difference to &amp;quot;normal&amp;quot; module installation the Discover method probably did not add an entry to the module instances list. The name is mod_yourmodule so you&#039;ll find it lower case sorted to the end of the list . We&#039;ll fix that in the next tutorial part.&lt;br /&gt;
&lt;br /&gt;
Info for new Joomla! users: You can create multiple instances/copies of a module. Each with different option settings. That is what you do when you click on the New button.&lt;br /&gt;
&lt;br /&gt;
Add a title, choose a module position and publish. Go to the frontend and see your first module creation. You can now modify the default.php file to get something fancy before you go on to the next step in the tutorial.&lt;br /&gt;
&lt;br /&gt;
{{Tip|To remember for ever. Do not forget to click the Menu Assignment tab in the Module Manager. Promised: You will! }}&lt;br /&gt;
&lt;br /&gt;
More about [[Module|Joomla! Modules]]&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Overrides&amp;diff=125233</id>
		<title>User:Over/Step by step to a Joomla Module - Overrides</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Overrides&amp;diff=125233"/>
		<updated>2014-09-06T03:41:40Z</updated>

		<summary type="html">&lt;p&gt;Over: /* The html/layouts path */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
In this step we&#039;ll use your custom module to show you how you can use the powerful Joomla! methods to override ( = change ) the output. The same possibilities are valid for all modules and components that follows the Joomla! best practice.&lt;br /&gt;
&lt;br /&gt;
=== Your site template directory ===&lt;br /&gt;
&lt;br /&gt;
As you probably know, your template is found under the templates/ folder in your Joomla! directory. The folders important for our overrides are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/templates&lt;br /&gt;
  ...&lt;br /&gt;
  /mytemplate&lt;br /&gt;
    /css&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule.css&lt;br /&gt;
      ...&lt;br /&gt;
    /html&lt;br /&gt;
      ...&lt;br /&gt;
      /com_mycomponent&lt;br /&gt;
        /view1&lt;br /&gt;
          default.php&lt;br /&gt;
        /view2&lt;br /&gt;
          default.php&lt;br /&gt;
      ...&lt;br /&gt;
      /layouts&lt;br /&gt;
        /joomla&lt;br /&gt;
          /content&lt;br /&gt;
            /info_block&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        default.php          &lt;br /&gt;
        alternative.php&lt;br /&gt;
      ...&lt;br /&gt;
    /images&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule-logo.png&lt;br /&gt;
      ...&lt;br /&gt;
    /js&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule.js&lt;br /&gt;
    ...&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The illustration above shows the paths and some of the files in your templates folder.&lt;br /&gt;
If we add files in those directories, they will be used instead of the extensions original files.&lt;br /&gt;
You can use the Template Manager to easily create overrides in the html path.  [[J3.x:How_to_use_the_Template_Manager|J3.x:How to use the Template Manager]]&lt;br /&gt;
&lt;br /&gt;
Be aware of that if you use a template including overrides, you have to find a way to protect your custom overrides when the template is updated. e.g. if you use the Beez3 template, you can create a copy of this template. See the Template Manager.&lt;br /&gt;
&lt;br /&gt;
We can also override css, images and javascripts that are loaded with the JHtml functions and &#039;relative&#039; to the media/ folder. We&#039;ll show this with the custom module you have created in this tutorial.&lt;br /&gt;
&lt;br /&gt;
=== Overriding ===&lt;br /&gt;
&lt;br /&gt;
Use the Template Manager or your file manager to copy the default.php from the /tmpl folder in your module to yourtemplate/html/mod_yourmodule/ as shown above. Open the copy with your editor and make some visual changes. Maybe you want to replace the Bootstrap classes if your template is not loading the Bootstrap Css. If you now refresh the browser page you&#039;ll see the changes.&lt;br /&gt;
&lt;br /&gt;
You can create a second override for your module with another name. e.g. alternative.php and change some visible content. Now you click New in the Module Manager and choose your module. Edit the new copy of the module and choose the second override in the Advanced tab / Alternative Layout. Enable and have a look what happend. &lt;br /&gt;
&lt;br /&gt;
You can do the same with components. As shown above, you have to add one folder per component view, where you add the output file. The name is not always default.php.  &lt;br /&gt;
&lt;br /&gt;
Copy the yourmodule.css file from media/mod_yourmodule/css to yourtemplate/css/mod_yourmodule/. Open this file and change css classes e.g. text to another color. Reload the page in the browser. Be aware of the browser cache. It can be, that you have to clear it to get the changed css loaded.&lt;br /&gt;
&lt;br /&gt;
Copy an image to yourtemplate/images/mod_yourmodule/ and rename it to the same name as used in the default.php. Reload the page and you&#039;ll see your image.&lt;br /&gt;
&lt;br /&gt;
The same possibility is valid for javascript. If they are loaded &#039;relative&#039; to the media/ path you can copy them to yourtemplate/js/mod_yourmodule/ and change them.&lt;br /&gt;
&lt;br /&gt;
As you remember we added two options to the module settings, load_css and load_js. A administrator/user may want to load css and/or javascript in other ways. If you use those parameters, the administrator can turn off the loading of your modules css and/or javacript without overriding the default.php. This is more important for components as css and javascript normaly not is loaded in overridable code.&lt;br /&gt;
&lt;br /&gt;
Example - optional exclusion of the css:&lt;br /&gt;
==== default.php Css parameter ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
if ($params-&amp;gt;get(&#039;load_css&#039;, 1)) {&lt;br /&gt;
   JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The html/layouts path ===&lt;br /&gt;
&lt;br /&gt;
A new possibility to Joomla! output is the reuse of parts of a view ( JLayout ).  An example is the use of the same &#039;layout&#039; in many of the different article views.  JLayout files use the layout paths. In the Joomla! root you can find a /layouts folder that include the core JLayout files. Have a look at the available ones. Third party components usually use an own folder in their backend path.&lt;br /&gt;
&lt;br /&gt;
To override those reused &#039;layouts&#039; you copy them to the corresponding path in your templates directory and make the changes. They will be automaticly loaded instead of the original one.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not likely that you can reuse a JLayout file in a module, but it is possible.&lt;br /&gt;
&lt;br /&gt;
=== Language string overrides ===&lt;br /&gt;
&lt;br /&gt;
We will not describe this type of overrides here. We only want to remind you of the possibility to change language strings in extensions that are not your own. Do not change the original files.&lt;br /&gt;
&lt;br /&gt;
Go to {{rarr|Extensions,Language Manager,Overrides}} to create overrides that change texts.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Overrides&amp;diff=125232</id>
		<title>User:Over/Step by step to a Joomla Module - Overrides</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Overrides&amp;diff=125232"/>
		<updated>2014-09-06T03:15:05Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Overriding */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
In this step we&#039;ll use your custom module to show you how you can use the powerful Joomla! methods to override ( = change ) the output. The same possibilities are valid for all modules and components that follows the Joomla! best practice.&lt;br /&gt;
&lt;br /&gt;
=== Your site template directory ===&lt;br /&gt;
&lt;br /&gt;
As you probably know, your template is found under the templates/ folder in your Joomla! directory. The folders important for our overrides are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/templates&lt;br /&gt;
  ...&lt;br /&gt;
  /mytemplate&lt;br /&gt;
    /css&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule.css&lt;br /&gt;
      ...&lt;br /&gt;
    /html&lt;br /&gt;
      ...&lt;br /&gt;
      /com_mycomponent&lt;br /&gt;
        /view1&lt;br /&gt;
          default.php&lt;br /&gt;
        /view2&lt;br /&gt;
          default.php&lt;br /&gt;
      ...&lt;br /&gt;
      /layouts&lt;br /&gt;
        /joomla&lt;br /&gt;
          /content&lt;br /&gt;
            /info_block&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        default.php          &lt;br /&gt;
        alternative.php&lt;br /&gt;
      ...&lt;br /&gt;
    /images&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule-logo.png&lt;br /&gt;
      ...&lt;br /&gt;
    /js&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule.js&lt;br /&gt;
    ...&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The illustration above shows the paths and some of the files in your templates folder.&lt;br /&gt;
If we add files in those directories, they will be used instead of the extensions original files.&lt;br /&gt;
You can use the Template Manager to easily create overrides in the html path.  [[J3.x:How_to_use_the_Template_Manager|J3.x:How to use the Template Manager]]&lt;br /&gt;
&lt;br /&gt;
Be aware of that if you use a template including overrides, you have to find a way to protect your custom overrides when the template is updated. e.g. if you use the Beez3 template, you can create a copy of this template. See the Template Manager.&lt;br /&gt;
&lt;br /&gt;
We can also override css, images and javascripts that are loaded with the JHtml functions and &#039;relative&#039; to the media/ folder. We&#039;ll show this with the custom module you have created in this tutorial.&lt;br /&gt;
&lt;br /&gt;
=== Overriding ===&lt;br /&gt;
&lt;br /&gt;
Use the Template Manager or your file manager to copy the default.php from the /tmpl folder in your module to yourtemplate/html/mod_yourmodule/ as shown above. Open the copy with your editor and make some visual changes. Maybe you want to replace the Bootstrap classes if your template is not loading the Bootstrap Css. If you now refresh the browser page you&#039;ll see the changes.&lt;br /&gt;
&lt;br /&gt;
You can create a second override for your module with another name. e.g. alternative.php and change some visible content. Now you click New in the Module Manager and choose your module. Edit the new copy of the module and choose the second override in the Advanced tab / Alternative Layout. Enable and have a look what happend. &lt;br /&gt;
&lt;br /&gt;
You can do the same with components. As shown above, you have to add one folder per component view, where you add the output file. The name is not always default.php.  &lt;br /&gt;
&lt;br /&gt;
Copy the yourmodule.css file from media/mod_yourmodule/css to yourtemplate/css/mod_yourmodule/. Open this file and change css classes e.g. text to another color. Reload the page in the browser. Be aware of the browser cache. It can be, that you have to clear it to get the changed css loaded.&lt;br /&gt;
&lt;br /&gt;
Copy an image to yourtemplate/images/mod_yourmodule/ and rename it to the same name as used in the default.php. Reload the page and you&#039;ll see your image.&lt;br /&gt;
&lt;br /&gt;
The same possibility is valid for javascript. If they are loaded &#039;relative&#039; to the media/ path you can copy them to yourtemplate/js/mod_yourmodule/ and change them.&lt;br /&gt;
&lt;br /&gt;
As you remember we added two options to the module settings, load_css and load_js. A administrator/user may want to load css and/or javascript in other ways. If you use those parameters, the administrator can turn off the loading of your modules css and/or javacript without overriding the default.php. This is more important for components as css and javascript normaly not is loaded in overridable code.&lt;br /&gt;
&lt;br /&gt;
Example - optional exclusion of the css:&lt;br /&gt;
==== default.php Css parameter ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
if ($params-&amp;gt;get(&#039;load_css&#039;, 1)) {&lt;br /&gt;
   JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The html/layouts path ===&lt;br /&gt;
&lt;br /&gt;
A new possibility to Joomla! output is the reuse of parts of a view ( JLayout ).  An example is the use of the same &#039;layout&#039; in many of the different article views.  JLayout files use the layout paths. In the Joomla! root you can find a /layouts folder that include the core JLayout files. Have a look at the available ones. Third party components usually use an own folder in their backend path.&lt;br /&gt;
&lt;br /&gt;
To override those reused &#039;layouts&#039; you copy them to the corresponding path in your templates directory and make the changes. They will be automaticly loaded instead of the original one.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not likely that you can reuse a JLayout file in a module, but it is possible.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125231</id>
		<title>User:Over/Step by step to a Joomla Module - Installation package</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125231"/>
		<updated>2014-09-06T02:27:12Z</updated>

		<summary type="html">&lt;p&gt;Over: /* en-GB.mod_yourmodule.ini */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to become an installable extension for any Joomla! 3.x site. e.g. after testing the functionality on your local installation you can upload and install it on your live site with a few clicks.&lt;br /&gt;
&lt;br /&gt;
=== Language files ===&lt;br /&gt;
&lt;br /&gt;
The language files hold the textstrings that are used for descriptions, field labels, field descriptions and any other static texts. You can also translate the textstrings for any language code. The default language code is en-GB, Great Britain english. In version 3 the english &amp;quot;translation&amp;quot; is in most cases loaded before any other specific language. i.e. you should always keep those files up to date.&lt;br /&gt;
&lt;br /&gt;
As in the first part of the tutorial we&#039;ll use skeleton files. In the folder, where you unzipped the downloaded file, you can find two language files, en-GB.mod_yourmodule.ini and en-GB.mod_yourmodule.sys.ini Copy those to the Joomla! en-GB language folder. path/to/joomla/language/en-GB. You can also find a language folder in the administrator/ path used for backend extensions and all plug ins.&lt;br /&gt;
&lt;br /&gt;
As always, change files named ...yourmodule... to the name you did choose. Open the first file en-GB.mod_yourmodule.ini&lt;br /&gt;
&lt;br /&gt;
===== en-GB.mod_yourmodule.ini =====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Copyright (C) 2014 Joomla Doe&lt;br /&gt;
; Translater Joomla Doe&lt;br /&gt;
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php&lt;br /&gt;
; Note : All ini files need to be saved as UTF-8 - No BOM&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE=&amp;quot;Your own module&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of my module. This one in .ini is shown when editing the module in the Module Manager. Yoü can e.g. add some tips to the confuguration and a link to a help page on your site&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the top we find some comments. As you see, you have to use ; in front of the comments. If you have friendly helpers that translate your extension, it&#039;s nice to have a line with the translators name. The use of character set UTF-8 is noted. For the language string constants you should follow the Joomla! best practice i.e. start all language constants with the extension name. &#039;&#039;&#039;The language constants have to be in upper case with _ (underscore) as divider ending with a =. The text has to be within &amp;quot; double quote.&#039;&#039;&#039; Do not use double quote within the text or you will have to find out how to use __QQ__. &#039;&#039;&#039;No line break is allowed!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
; An example with double quote&lt;br /&gt;
MOD_YOURMODULE_MY_QUOTE=&amp;quot;My value is &amp;quot;_QQ_&amp;quot;great!&amp;quot;_QQ_&amp;quot;. I like it&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is no good reference available at the time of writing. Please change this link if a better is found. [[Specification_of_language_files|Specification of language files]]&lt;br /&gt;
&lt;br /&gt;
Change the two MOD_YOURMODULE, change the first text to a &amp;quot;human&amp;quot; name of your module and change the description. Again: in one line! &#039;&#039;&#039;no line break is allowed!&#039;&#039;&#039;. If you add e.g. a link remeber &amp;quot;_QQ_&amp;quot; for double quotes. Save this file and copy the text except the description content. The second file has almost the same content at this stage. Open en-GB.mod_yourmodule.sys.ini and paste the copied text replacing the text i.e. not the description text.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of your module. This one in .sys.ini is shown when choosing a new module in the module manager and in the extension manager. Keep this shorter.&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the description and save.&lt;br /&gt;
&lt;br /&gt;
The difference between those is that the .sys.ini file is loaded in cases like module lists where no module fields are shown. We´ll see another use of the .sys.ini below.&lt;br /&gt;
&lt;br /&gt;
As promised in the first part of the tutorial, you can now see the reason for using mod_yourmodule as module name in the xml file. Go to Module Manager, click on new. You will find your module with the name from the language file. Next we will fix the description. Before you close the files copy the constant MOD_YOURMODULE_XML_DESCRIPTION.&lt;br /&gt;
&lt;br /&gt;
Open mod_yourmodule.xml from the server and find the description line. Replace the description with your copied language constant MOD_YOURMODULE_XML_DESCRIPTION.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Description ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;MOD_YOURMODULE_XML_DESCRIPTION&amp;lt;/description&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can make the same test as before in the Module Manager and you&#039;ll see that the description comes from the language files.&lt;br /&gt;
&lt;br /&gt;
=== Parameters - Options ===&lt;br /&gt;
If you choose your enabled module for edit in the Module Manager you&#039;ll se some default options under the advanced tab. Let&#039;s add some more options in the xml file and add the used language strings before we create the first installable package.&lt;br /&gt;
&lt;br /&gt;
Add the following where you find the config part. We will see more around form fields in a later tutorial part.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Config ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;config&amp;gt;&lt;br /&gt;
      &amp;lt;fields name=&amp;quot;params&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;options&amp;quot; label=&amp;quot;COM_MODULES_BASIC_FIELDSET_LABEL&amp;quot;&lt;br /&gt;
            addfieldpath=&amp;quot;/administrator/components/com_content/models/fields/modal&amp;quot;&lt;br /&gt;
	 &amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;article_id&amp;quot;&lt;br /&gt;
               type=&amp;quot;modal_article&amp;quot;&lt;br /&gt;
               default=&amp;quot;&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_DESC&amp;quot; &amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;advanced&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_css&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_js&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;layout&amp;quot;&lt;br /&gt;
               type=&amp;quot;modulelayout&amp;quot;&lt;br /&gt;
               label=&amp;quot;JFIELD_ALT_LAYOUT_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;JFIELD_ALT_MODULE_LAYOUT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;moduleclass_sfx&amp;quot;&lt;br /&gt;
               type=&amp;quot;textarea&amp;quot; rows=&amp;quot;3&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache&amp;quot;&lt;br /&gt;
               type=&amp;quot;list&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHING_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHING_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JGLOBAL_USE_GLOBAL&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;COM_MODULES_FIELD_VALUE_NOCACHING&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache_time&amp;quot;&lt;br /&gt;
               type=&amp;quot;text&amp;quot;&lt;br /&gt;
               default=&amp;quot;900&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cachemode&amp;quot;&lt;br /&gt;
               type=&amp;quot;hidden&amp;quot;&lt;br /&gt;
               default=&amp;quot;static&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;static&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
      &amp;lt;/fields&amp;gt;&lt;br /&gt;
   &amp;lt;/config&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the fieldset options we add an option field &amp;quot;article_id&amp;quot; that we will use later. This field calls a modal window where you can choose an article. Fieldset options is shown in the tab Options in the Module Manager. If you use a fieldset named basic you&#039;ll have those fields in the first tab. We also add some standard option fields to the &amp;quot;Advanced&amp;quot; tab. We do not have to add the text constants used in the Advanced part since they are standard. Remains the two strings used for the article field. Well, we added two fields in the advanced tab, load_css and load_js with language strings that need to be added. We&#039;ll come back to the use of those options later. &lt;br /&gt;
&lt;br /&gt;
Follow this link to read more about [http://docs.joomla.org/Module Joomla modules and the Modules Manager]&lt;br /&gt;
&lt;br /&gt;
=== Add strings to language file ===&lt;br /&gt;
Save the xml file and open the language file. The one without .sys.&lt;br /&gt;
&lt;br /&gt;
Add the 6 strings and save.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.ini - New strings ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_DESC=&amp;quot;Choose an article to be shown by the module.&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_LABEL=&amp;quot;Article&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_DESC=&amp;quot;You can disable the modules css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL=&amp;quot;Load Css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_DESC=&amp;quot;You can disable the modules JavaScript&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_LABEL=&amp;quot;Load JavaScript&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Final change to the xml file ===&lt;br /&gt;
&lt;br /&gt;
Before we create the first installation file we will add the language tags to the xml file below the &amp;lt;/files&amp;gt; tag.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Final ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
   &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We use a folder named langs here, because we will use the folder language for a trick. If you include other language files just add lines with the correspondent language identifier.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;large-12 panel radius&amp;quot; style=&amp;quot;background-color:#fff; border:1px solid #aaa; margin:1em 0;&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;For those of you that have some knowledge of Joomla development:&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
Do not add the /language folder to the xml file. It is autoloaded. i.e. extracted and used in the installation process by default.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the xml file.&lt;br /&gt;
&lt;br /&gt;
=== Create the compressed installation file ===&lt;br /&gt;
Now we have everything to create the first version of the installation file.&lt;br /&gt;
&lt;br /&gt;
Inside the folder you created on yor local system at the start of the tutorial &#039;somewhere&#039;/j_module_tutorial/new_module you add three sub directories. langs, language and tmpl. Now you copy the files in the other direction. From the web directory to the new one. It should look something like this ( remember - yourmodule - is a placeholder for your choosen module name ):&lt;br /&gt;
&lt;br /&gt;
* .../new_module&lt;br /&gt;
** /langs&lt;br /&gt;
*** en-GB.mod_yourmodule.ini&lt;br /&gt;
*** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
*** anyother-language.mod_yourmodule.in&lt;br /&gt;
*** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
** /language&lt;br /&gt;
*** /en-GB&lt;br /&gt;
**** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
*** /anyother-language&lt;br /&gt;
**** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
** /tmpl&lt;br /&gt;
*** default.php&lt;br /&gt;
** mod_yourmodule.php&lt;br /&gt;
** mod_yourmodule.xml&lt;br /&gt;
&lt;br /&gt;
As a last step we&#039;ll edit the .../new_module/language/en-GB/mod_yourmodule.sys.ini to show a different message at installation/upgrade.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.sys.ini - Installation message ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;Thank you for installing / update the Your own module. This module displays an article text in a module position. To activate you go to the module manager and edit this module or create a new entry. Select the article you want to show. Please visit www.mysite.com for more information. If you like it please add a review on JED.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you edit the description text to include a &amp;quot;Thanks&amp;quot; and other informations only relevant directly after the installation / upgrade this is a trick to achieve this. Only .../new_module/langs/language-codes.mod_yourmodule.sys.ini will be copied and used after the installation.&lt;br /&gt;
&lt;br /&gt;
You can find two short descriptions of alternative handling of the language files at the end of this page.&lt;br /&gt;
&lt;br /&gt;
Now we compress the files. The Zip type is recommended as it has native support by most systems. In Windows you go to the .../new_module folder. Mark the included folders and files, right click and choose {{rarr|Send to,ZIP compressed folder}}.&lt;br /&gt;
&lt;br /&gt;
Rename the .zip file to mod_yourmodule_1_0_0.zip i.e. including the version number. You should better move this file to another folder. It is easy forgotten NOT to include it, the next time you create a zipped file.&lt;br /&gt;
&lt;br /&gt;
You made a backup before starting the tutorial? Well, only in case of ...&lt;br /&gt;
&lt;br /&gt;
First you uninstall the module to get a complete new installation {{rarr|Extensions,Manager,Manage}} Look up the module. Filter e.g. Location = Site, Type=Module and/or name.&lt;br /&gt;
&lt;br /&gt;
When the module is uninstalled you go to Install, browse to your installation zip file and click the Upload &amp;amp;amp; Install button. You&#039;ll see the description you edited as installation message. Go to the Module Manager. This time you should find an entry in the Module list. Choose this and enable it, as you did after the Discover in the first part of the tutorial. You can also see that the description is the one from your .ini file. To check the description from .sys.ini click on NEW module. This is not the one you saw directly after the installation.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this part of the module tutorial. The next part will show you how to retrieve data and add some Css styling to your module.&lt;br /&gt;
&lt;br /&gt;
=== Alternative language files  handling ===&lt;br /&gt;
&lt;br /&gt;
For both alternatives you have to add all language files to subfolders in the /language folder. Be aware that the folder name is mandatory! &lt;br /&gt;
&lt;br /&gt;
You can use the language files from the /langs folder in the example above. Do not add a long description to the .sys.ini files, as it will be used for the module lists. Of course you have to remove the /langs folder, if you want to test by changing the example above.&lt;br /&gt;
&lt;br /&gt;
Resulting folder:&lt;br /&gt;
&lt;br /&gt;
* /language&lt;br /&gt;
** /en-GB&lt;br /&gt;
*** en-GB.mod_yourmodule.ini&lt;br /&gt;
*** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
** /anyother-language&lt;br /&gt;
*** anyother-language.mod_yourmodule.ini&lt;br /&gt;
*** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
&lt;br /&gt;
==== 1. Easiest way  ====&lt;br /&gt;
&lt;br /&gt;
Add a folder tag to the files area in the xml file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;folder&amp;gt;language&amp;lt;/folder&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The folder will be stored in the extensions folder and no files in the core language folder.&lt;br /&gt;
ALL files are copied, not only the ones for installed languages.&lt;br /&gt;
&lt;br /&gt;
==== 2. Traditional way  ====&lt;br /&gt;
&lt;br /&gt;
Add all single language files to the languages tag in the xml file. Be aware of the extra folder name required (= language tag).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;language&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt; &lt;br /&gt;
  &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files are saved to the core language folder in the traditional way.&lt;br /&gt;
Only the files for installed languages are copied.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125230</id>
		<title>User:Over/Step by step to a Joomla Module - Installation package</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125230"/>
		<updated>2014-09-06T02:15:09Z</updated>

		<summary type="html">&lt;p&gt;Over: /* mod_yourmodule.sys.ini - Installation message */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to become an installable extension for any Joomla! 3.x site. e.g. after testing the functionality on your local installation you can upload and install it on your live site with a few clicks.&lt;br /&gt;
&lt;br /&gt;
=== Language files ===&lt;br /&gt;
&lt;br /&gt;
The language files hold the textstrings that are used for descriptions, field labels, field descriptions and any other static texts. You can also translate the textstrings for any language code. The default language code is en-GB, Great Britain english. In version 3 the english &amp;quot;translation&amp;quot; is in most cases loaded before any other specific language. i.e. you should always keep those files up to date.&lt;br /&gt;
&lt;br /&gt;
As in the first part of the tutorial we&#039;ll use skeleton files. In the folder, where you unzipped the downloaded file, you can find two language files, en-GB.mod_yourmodule.ini and en-GB.mod_yourmodule.sys.ini Copy those to the Joomla! en-GB language folder. path/to/joomla/language/en-GB. You can also find a language folder in the administrator/ path used for backend extensions and all plug ins.&lt;br /&gt;
&lt;br /&gt;
As always, change files named ...yourmodule... to the name you did choose. Open the first file en-GB.mod_yourmodule.ini&lt;br /&gt;
&lt;br /&gt;
===== en-GB.mod_yourmodule.ini =====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Copyright (C) 2014 Joomla Doe&lt;br /&gt;
; Translater Joomla Doe&lt;br /&gt;
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php&lt;br /&gt;
; Note : All ini files need to be saved as UTF-8 - No BOM&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE=&amp;quot;Your own module&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of my module. This one in .ini is shown when editing the module in the Module Manager. Yoü can e.g. add some tips to the confuguration and a link to a help page on your site&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the top we find some comments. As you see, you have to use ; in front of the comments. If you have friendly helpers that translate your extension, it&#039;s nice to have a line with the translators name. The use of character set UTF-8 is noted. For the language string constants you should follow the Joomla! best practice i.e. start all language constants with the extension name. &#039;&#039;&#039;The language constants have to be in upper case with _ (underscore) as divider ending with a =. The text has to be within &amp;quot; double quote.&#039;&#039;&#039; Do not use double quote within the text or you will have to find out how to use __QQ__. &#039;&#039;&#039;No line break is allowed!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
; An example with double quote&lt;br /&gt;
MOD_YOURMODULE_MY_QUOTE=&amp;quot;My value is &amp;quot;_QQ_&amp;quot;great!&amp;quot;_QQ_&amp;quot;. I like it&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is no good reference available at the time of writing. Please change this link if a better is found. [[Specification_of_language_files|Specification of language files]]&lt;br /&gt;
&lt;br /&gt;
Change the two MOD_YOURMODULE, change the first text to a &amp;quot;human&amp;quot; name of your module and change the description. Again: in one line! &#039;&#039;&#039;no line break is allowed!&#039;&#039;&#039;. If you add e.g. a link remeber &amp;quot;_QQ_&amp;quot; for double quotes. Save this file and copy the text except the description content. The second file has almost the same content at this stage. Open en-GB.mod_yourmodule.sys.ini and paste the copied text replacing the text i.e. not the description text.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of your module. This one in .sys.ini is shown when choosing a new module in the module manager and in the extension manager. Keep this shorter.&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the description and save.&lt;br /&gt;
&lt;br /&gt;
The difference between those is that the .sys.ini file is loaded in cases like module lists where no module fields are shown. We´ll see another use of the .sys.ini below.&lt;br /&gt;
&lt;br /&gt;
As promised in the first part of the tutorial, you can now see the reason for using mod_yourmodule as module name in the xml file. Go to Module Manager, click on new. You will find your module with the name from the language file. Next we will fix the description. Before you close the files copy the constant MOD_YOURMODULE_XML_DESCRIPTION-&lt;br /&gt;
&lt;br /&gt;
Open mod_yourmodule.xml from the server and find the description line. Replace the description with your copied language constant MOD_YOURMODULE_XML_DESCRIPTION.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Description ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;MOD_YOURMODULE_XML_DESCRIPTION&amp;lt;/description&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can make the same test as before in the Module Manager and you&#039;ll see that the description comes from the language files.&lt;br /&gt;
&lt;br /&gt;
=== Parameters - Options ===&lt;br /&gt;
If you choose your enabled module for edit in the Module Manager you&#039;ll se some default options under the advanced tab. Let&#039;s add some more options in the xml file and add the used language strings before we create the first installable package.&lt;br /&gt;
&lt;br /&gt;
Add the following where you find the config part. We will see more around form fields in a later tutorial part.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Config ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;config&amp;gt;&lt;br /&gt;
      &amp;lt;fields name=&amp;quot;params&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;options&amp;quot; label=&amp;quot;COM_MODULES_BASIC_FIELDSET_LABEL&amp;quot;&lt;br /&gt;
            addfieldpath=&amp;quot;/administrator/components/com_content/models/fields/modal&amp;quot;&lt;br /&gt;
	 &amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;article_id&amp;quot;&lt;br /&gt;
               type=&amp;quot;modal_article&amp;quot;&lt;br /&gt;
               default=&amp;quot;&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_DESC&amp;quot; &amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;advanced&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_css&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_js&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;layout&amp;quot;&lt;br /&gt;
               type=&amp;quot;modulelayout&amp;quot;&lt;br /&gt;
               label=&amp;quot;JFIELD_ALT_LAYOUT_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;JFIELD_ALT_MODULE_LAYOUT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;moduleclass_sfx&amp;quot;&lt;br /&gt;
               type=&amp;quot;textarea&amp;quot; rows=&amp;quot;3&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache&amp;quot;&lt;br /&gt;
               type=&amp;quot;list&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHING_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHING_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JGLOBAL_USE_GLOBAL&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;COM_MODULES_FIELD_VALUE_NOCACHING&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache_time&amp;quot;&lt;br /&gt;
               type=&amp;quot;text&amp;quot;&lt;br /&gt;
               default=&amp;quot;900&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cachemode&amp;quot;&lt;br /&gt;
               type=&amp;quot;hidden&amp;quot;&lt;br /&gt;
               default=&amp;quot;static&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;static&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
      &amp;lt;/fields&amp;gt;&lt;br /&gt;
   &amp;lt;/config&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the fieldset options we add an option field &amp;quot;article_id&amp;quot; that we will use later. This field calls a modal window where you can choose an article. Fieldset options is shown in the tab Options in the Module Manager. If you use a fieldset named basic you&#039;ll have those fields in the first tab. We also add some standard option fields to the &amp;quot;Advanced&amp;quot; tab. We do not have to add the text constants used in the Advanced part since they are standard. Remains the two strings used for the article field. Well, we added two fields in the advanced tab, load_css and load_js with language strings that need to be added. We&#039;ll come back to the use of those options later. &lt;br /&gt;
&lt;br /&gt;
Follow this link to read more about [http://docs.joomla.org/Module Joomla modules and the Modules Manager]&lt;br /&gt;
&lt;br /&gt;
=== Add strings to language file ===&lt;br /&gt;
Save the xml file and open the language file. The one without .sys.&lt;br /&gt;
&lt;br /&gt;
Add the 6 strings and save.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.ini - New strings ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_DESC=&amp;quot;Choose an article to be shown by the module.&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_LABEL=&amp;quot;Article&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_DESC=&amp;quot;You can disable the modules css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL=&amp;quot;Load Css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_DESC=&amp;quot;You can disable the modules JavaScript&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_LABEL=&amp;quot;Load JavaScript&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Final change to the xml file ===&lt;br /&gt;
&lt;br /&gt;
Before we create the first installation file we will add the language tags to the xml file below the &amp;lt;/files&amp;gt; tag.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Final ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
   &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We use a folder named langs here, because we will use the folder language for a trick. If you include other language files just add lines with the correspondent language identifier.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;large-12 panel radius&amp;quot; style=&amp;quot;background-color:#fff; border:1px solid #aaa; margin:1em 0;&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;For those of you that have some knowledge of Joomla development:&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
Do not add the /language folder to the xml file. It is autoloaded. i.e. extracted and used in the installation process by default.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the xml file.&lt;br /&gt;
&lt;br /&gt;
=== Create the compressed installation file ===&lt;br /&gt;
Now we have everything to create the first version of the installation file.&lt;br /&gt;
&lt;br /&gt;
Inside the folder you created on yor local system at the start of the tutorial &#039;somewhere&#039;/j_module_tutorial/new_module you add three sub directories. langs, language and tmpl. Now you copy the files in the other direction. From the web directory to the new one. It should look something like this ( remember - yourmodule - is a placeholder for your choosen module name ):&lt;br /&gt;
&lt;br /&gt;
* .../new_module&lt;br /&gt;
** /langs&lt;br /&gt;
*** en-GB.mod_yourmodule.ini&lt;br /&gt;
*** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
*** anyother-language.mod_yourmodule.in&lt;br /&gt;
*** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
** /language&lt;br /&gt;
*** /en-GB&lt;br /&gt;
**** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
*** /anyother-language&lt;br /&gt;
**** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
** /tmpl&lt;br /&gt;
*** default.php&lt;br /&gt;
** mod_yourmodule.php&lt;br /&gt;
** mod_yourmodule.xml&lt;br /&gt;
&lt;br /&gt;
As a last step we&#039;ll edit the .../new_module/language/en-GB/mod_yourmodule.sys.ini to show a different message at installation/upgrade.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.sys.ini - Installation message ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;Thank you for installing / update the Your own module. This module displays an article text in a module position. To activate you go to the module manager and edit this module or create a new entry. Select the article you want to show. Please visit www.mysite.com for more information. If you like it please add a review on JED.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you edit the description text to include a &amp;quot;Thanks&amp;quot; and other informations only relevant directly after the installation / upgrade this is a trick to achieve this. Only .../new_module/langs/language-codes.mod_yourmodule.sys.ini will be copied and used after the installation.&lt;br /&gt;
&lt;br /&gt;
You can find two short descriptions of alternative handling of the language files at the end of this page.&lt;br /&gt;
&lt;br /&gt;
Now we compress the files. The Zip type is recommended as it has native support by most systems. In Windows you go to the .../new_module folder. Mark the included folders and files, right click and choose {{rarr|Send to,ZIP compressed folder}}.&lt;br /&gt;
&lt;br /&gt;
Rename the .zip file to mod_yourmodule_1_0_0.zip i.e. including the version number. You should better move this file to another folder. It is easy forgotten NOT to include it, the next time you create a zipped file.&lt;br /&gt;
&lt;br /&gt;
You made a backup before starting the tutorial? Well, only in case of ...&lt;br /&gt;
&lt;br /&gt;
First you uninstall the module to get a complete new installation {{rarr|Extensions,Manager,Manage}} Look up the module. Filter e.g. Location = Site, Type=Module and/or name.&lt;br /&gt;
&lt;br /&gt;
When the module is uninstalled you go to Install, browse to your installation zip file and click the Upload &amp;amp;amp; Install button. You&#039;ll see the description you edited as installation message. Go to the Module Manager. This time you should find an entry in the Module list. Choose this and enable it, as you did after the Discover in the first part of the tutorial. You can also see that the description is the one from your .ini file. To check the description from .sys.ini click on NEW module. This is not the one you saw directly after the installation.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this part of the module tutorial. The next part will show you how to retrieve data and add some Css styling to your module.&lt;br /&gt;
&lt;br /&gt;
=== Alternative language files  handling ===&lt;br /&gt;
&lt;br /&gt;
For both alternatives you have to add all language files to subfolders in the /language folder. Be aware that the folder name is mandatory! &lt;br /&gt;
&lt;br /&gt;
You can use the language files from the /langs folder in the example above. Do not add a long description to the .sys.ini files, as it will be used for the module lists. Of course you have to remove the /langs folder, if you want to test by changing the example above.&lt;br /&gt;
&lt;br /&gt;
Resulting folder:&lt;br /&gt;
&lt;br /&gt;
* /language&lt;br /&gt;
** /en-GB&lt;br /&gt;
*** en-GB.mod_yourmodule.ini&lt;br /&gt;
*** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
** /anyother-language&lt;br /&gt;
*** anyother-language.mod_yourmodule.ini&lt;br /&gt;
*** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
&lt;br /&gt;
==== 1. Easiest way  ====&lt;br /&gt;
&lt;br /&gt;
Add a folder tag to the files area in the xml file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;folder&amp;gt;language&amp;lt;/folder&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The folder will be stored in the extensions folder and no files in the core language folder.&lt;br /&gt;
ALL files are copied, not only the ones for installed languages.&lt;br /&gt;
&lt;br /&gt;
==== 2. Traditional way  ====&lt;br /&gt;
&lt;br /&gt;
Add all single language files to the languages tag in the xml file. Be aware of the extra folder name required (= language tag).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;language&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt; &lt;br /&gt;
  &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files are saved to the core language folder in the traditional way.&lt;br /&gt;
Only the files for installed languages are copied.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125229</id>
		<title>User:Over/Step by step to a Joomla Module - Installation package</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125229"/>
		<updated>2014-09-06T02:03:31Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Create the compressed installation file */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to become an installable extension for any Joomla! 3.x site. e.g. after testing the functionality on your local installation you can upload and install it on your live site with a few clicks.&lt;br /&gt;
&lt;br /&gt;
=== Language files ===&lt;br /&gt;
&lt;br /&gt;
The language files hold the textstrings that are used for descriptions, field labels, field descriptions and any other static texts. You can also translate the textstrings for any language code. The default language code is en-GB, Great Britain english. In version 3 the english &amp;quot;translation&amp;quot; is in most cases loaded before any other specific language. i.e. you should always keep those files up to date.&lt;br /&gt;
&lt;br /&gt;
As in the first part of the tutorial we&#039;ll use skeleton files. In the folder, where you unzipped the downloaded file, you can find two language files, en-GB.mod_yourmodule.ini and en-GB.mod_yourmodule.sys.ini Copy those to the Joomla! en-GB language folder. path/to/joomla/language/en-GB. You can also find a language folder in the administrator/ path used for backend extensions and all plug ins.&lt;br /&gt;
&lt;br /&gt;
As always, change files named ...yourmodule... to the name you did choose. Open the first file en-GB.mod_yourmodule.ini&lt;br /&gt;
&lt;br /&gt;
===== en-GB.mod_yourmodule.ini =====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Copyright (C) 2014 Joomla Doe&lt;br /&gt;
; Translater Joomla Doe&lt;br /&gt;
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php&lt;br /&gt;
; Note : All ini files need to be saved as UTF-8 - No BOM&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE=&amp;quot;Your own module&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of my module. This one in .ini is shown when editing the module in the Module Manager. Yoü can e.g. add some tips to the confuguration and a link to a help page on your site&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the top we find some comments. As you see, you have to use ; in front of the comments. If you have friendly helpers that translate your extension, it&#039;s nice to have a line with the translators name. The use of character set UTF-8 is noted. For the language string constants you should follow the Joomla! best practice i.e. start all language constants with the extension name. &#039;&#039;&#039;The language constants have to be in upper case with _ (underscore) as divider ending with a =. The text has to be within &amp;quot; double quote.&#039;&#039;&#039; Do not use double quote within the text or you will have to find out how to use __QQ__. &#039;&#039;&#039;No line break is allowed!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
; An example with double quote&lt;br /&gt;
MOD_YOURMODULE_MY_QUOTE=&amp;quot;My value is &amp;quot;_QQ_&amp;quot;great!&amp;quot;_QQ_&amp;quot;. I like it&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is no good reference available at the time of writing. Please change this link if a better is found. [[Specification_of_language_files|Specification of language files]]&lt;br /&gt;
&lt;br /&gt;
Change the two MOD_YOURMODULE, change the first text to a &amp;quot;human&amp;quot; name of your module and change the description. Again: in one line! &#039;&#039;&#039;no line break is allowed!&#039;&#039;&#039;. If you add e.g. a link remeber &amp;quot;_QQ_&amp;quot; for double quotes. Save this file and copy the text except the description content. The second file has almost the same content at this stage. Open en-GB.mod_yourmodule.sys.ini and paste the copied text replacing the text i.e. not the description text.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of your module. This one in .sys.ini is shown when choosing a new module in the module manager and in the extension manager. Keep this shorter.&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the description and save.&lt;br /&gt;
&lt;br /&gt;
The difference between those is that the .sys.ini file is loaded in cases like module lists where no module fields are shown. We´ll see another use of the .sys.ini below.&lt;br /&gt;
&lt;br /&gt;
As promised in the first part of the tutorial, you can now see the reason for using mod_yourmodule as module name in the xml file. Go to Module Manager, click on new. You will find your module with the name from the language file. Next we will fix the description. Before you close the files copy the constant MOD_YOURMODULE_XML_DESCRIPTION-&lt;br /&gt;
&lt;br /&gt;
Open mod_yourmodule.xml from the server and find the description line. Replace the description with your copied language constant MOD_YOURMODULE_XML_DESCRIPTION.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Description ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;MOD_YOURMODULE_XML_DESCRIPTION&amp;lt;/description&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can make the same test as before in the Module Manager and you&#039;ll see that the description comes from the language files.&lt;br /&gt;
&lt;br /&gt;
=== Parameters - Options ===&lt;br /&gt;
If you choose your enabled module for edit in the Module Manager you&#039;ll se some default options under the advanced tab. Let&#039;s add some more options in the xml file and add the used language strings before we create the first installable package.&lt;br /&gt;
&lt;br /&gt;
Add the following where you find the config part. We will see more around form fields in a later tutorial part.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Config ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;config&amp;gt;&lt;br /&gt;
      &amp;lt;fields name=&amp;quot;params&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;options&amp;quot; label=&amp;quot;COM_MODULES_BASIC_FIELDSET_LABEL&amp;quot;&lt;br /&gt;
            addfieldpath=&amp;quot;/administrator/components/com_content/models/fields/modal&amp;quot;&lt;br /&gt;
	 &amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;article_id&amp;quot;&lt;br /&gt;
               type=&amp;quot;modal_article&amp;quot;&lt;br /&gt;
               default=&amp;quot;&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_DESC&amp;quot; &amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;advanced&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_css&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_js&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;layout&amp;quot;&lt;br /&gt;
               type=&amp;quot;modulelayout&amp;quot;&lt;br /&gt;
               label=&amp;quot;JFIELD_ALT_LAYOUT_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;JFIELD_ALT_MODULE_LAYOUT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;moduleclass_sfx&amp;quot;&lt;br /&gt;
               type=&amp;quot;textarea&amp;quot; rows=&amp;quot;3&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache&amp;quot;&lt;br /&gt;
               type=&amp;quot;list&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHING_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHING_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JGLOBAL_USE_GLOBAL&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;COM_MODULES_FIELD_VALUE_NOCACHING&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache_time&amp;quot;&lt;br /&gt;
               type=&amp;quot;text&amp;quot;&lt;br /&gt;
               default=&amp;quot;900&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cachemode&amp;quot;&lt;br /&gt;
               type=&amp;quot;hidden&amp;quot;&lt;br /&gt;
               default=&amp;quot;static&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;static&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
      &amp;lt;/fields&amp;gt;&lt;br /&gt;
   &amp;lt;/config&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the fieldset options we add an option field &amp;quot;article_id&amp;quot; that we will use later. This field calls a modal window where you can choose an article. Fieldset options is shown in the tab Options in the Module Manager. If you use a fieldset named basic you&#039;ll have those fields in the first tab. We also add some standard option fields to the &amp;quot;Advanced&amp;quot; tab. We do not have to add the text constants used in the Advanced part since they are standard. Remains the two strings used for the article field. Well, we added two fields in the advanced tab, load_css and load_js with language strings that need to be added. We&#039;ll come back to the use of those options later. &lt;br /&gt;
&lt;br /&gt;
Follow this link to read more about [http://docs.joomla.org/Module Joomla modules and the Modules Manager]&lt;br /&gt;
&lt;br /&gt;
=== Add strings to language file ===&lt;br /&gt;
Save the xml file and open the language file. The one without .sys.&lt;br /&gt;
&lt;br /&gt;
Add the 6 strings and save.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.ini - New strings ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_DESC=&amp;quot;Choose an article to be shown by the module.&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_LABEL=&amp;quot;Article&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_DESC=&amp;quot;You can disable the modules css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL=&amp;quot;Load Css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_DESC=&amp;quot;You can disable the modules JavaScript&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_LABEL=&amp;quot;Load JavaScript&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Final change to the xml file ===&lt;br /&gt;
&lt;br /&gt;
Before we create the first installation file we will add the language tags to the xml file below the &amp;lt;/files&amp;gt; tag.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Final ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
   &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We use a folder named langs here, because we will use the folder language for a trick. If you include other language files just add lines with the correspondent language identifier.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;large-12 panel radius&amp;quot; style=&amp;quot;background-color:#fff; border:1px solid #aaa; margin:1em 0;&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;For those of you that have some knowledge of Joomla development:&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
Do not add the /language folder to the xml file. It is autoloaded. i.e. extracted and used in the installation process by default.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the xml file.&lt;br /&gt;
&lt;br /&gt;
=== Create the compressed installation file ===&lt;br /&gt;
Now we have everything to create the first version of the installation file.&lt;br /&gt;
&lt;br /&gt;
Inside the folder you created on yor local system at the start of the tutorial &#039;somewhere&#039;/j_module_tutorial/new_module you add three sub directories. langs, language and tmpl. Now you copy the files in the other direction. From the web directory to the new one. It should look something like this ( remember - yourmodule - is a placeholder for your choosen module name ):&lt;br /&gt;
&lt;br /&gt;
* .../new_module&lt;br /&gt;
** /langs&lt;br /&gt;
*** en-GB.mod_yourmodule.ini&lt;br /&gt;
*** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
*** anyother-language.mod_yourmodule.in&lt;br /&gt;
*** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
** /language&lt;br /&gt;
*** /en-GB&lt;br /&gt;
**** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
*** /anyother-language&lt;br /&gt;
**** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
** /tmpl&lt;br /&gt;
*** default.php&lt;br /&gt;
** mod_yourmodule.php&lt;br /&gt;
** mod_yourmodule.xml&lt;br /&gt;
&lt;br /&gt;
As a last step we&#039;ll edit the .../new_module/language/en-GB/mod_yourmodule.sys.ini to show a different message at installation/upgrade.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.sys.ini - Installation message ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;Thank you for installing / update the Your own module. This module displays an article text in a module position. To activate you go to the module manager and edit this module or create a new entry. Select the article you want to show. Please visit www.mysite.com for more information. If you like it please add a review on JED.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you edit the description text to include a &amp;quot;Thanks&amp;quot; and other informations only relevant directly after the installation / upgrade this is a trick to achieve this. Only .../new_module/langs/mod_yourmodule.sys.ini will be copied and used after the installation.&lt;br /&gt;
&lt;br /&gt;
You can find two short descriptions of alternative handling of the language files at the end of this page.&lt;br /&gt;
&lt;br /&gt;
Now we compress the files. The Zip type is recommended as it has native support by most systems. In Windows you go to the .../new_module folder. Mark the included folders and files, right click and choose {{rarr|Send to,ZIP compressed folder}}.&lt;br /&gt;
&lt;br /&gt;
Rename the .zip file to mod_yourmodule_1_0_0.zip i.e. including the version number. You should better move this file to another folder. It is easy forgotten NOT to include it, the next time you create a zipped file.&lt;br /&gt;
&lt;br /&gt;
You made a backup before starting the tutorial? Well, only in case of ...&lt;br /&gt;
&lt;br /&gt;
First you uninstall the module to get a complete new installation {{rarr|Extensions,Manager,Manage}} Look up the module. Filter e.g. Location = Site, Type=Module and/or name.&lt;br /&gt;
&lt;br /&gt;
When the module is uninstalled you go to Install, browse to your installation zip file and click the Upload &amp;amp;amp; Install button. You&#039;ll see the description you edited as installation message. Go to the Module Manager. This time you should find an entry in the Module list. Choose this and enable it, as you did after the Discover in the first part of the tutorial. You can also see that the description is the one from your .ini file. To check the description from .sys.ini click on NEW module. This is not the one you saw directly after the installation.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this part of the module tutorial. The next part will show you how to retrieve data and add some Css styling to your module.&lt;br /&gt;
&lt;br /&gt;
=== Alternative language files  handling ===&lt;br /&gt;
&lt;br /&gt;
For both alternatives you have to add all language files to subfolders in the /language folder. Be aware that the folder name is mandatory! &lt;br /&gt;
&lt;br /&gt;
You can use the language files from the /langs folder in the example above. Do not add a long description to the .sys.ini files, as it will be used for the module lists. Of course you have to remove the /langs folder, if you want to test by changing the example above.&lt;br /&gt;
&lt;br /&gt;
Resulting folder:&lt;br /&gt;
&lt;br /&gt;
* /language&lt;br /&gt;
** /en-GB&lt;br /&gt;
*** en-GB.mod_yourmodule.ini&lt;br /&gt;
*** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
** /anyother-language&lt;br /&gt;
*** anyother-language.mod_yourmodule.ini&lt;br /&gt;
*** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
&lt;br /&gt;
==== 1. Easiest way  ====&lt;br /&gt;
&lt;br /&gt;
Add a folder tag to the files area in the xml file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;folder&amp;gt;language&amp;lt;/folder&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The folder will be stored in the extensions folder and no files in the core language folder.&lt;br /&gt;
ALL files are copied, not only the ones for installed languages.&lt;br /&gt;
&lt;br /&gt;
==== 2. Traditional way  ====&lt;br /&gt;
&lt;br /&gt;
Add all single language files to the languages tag in the xml file. Be aware of the extra folder name required (= language tag).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;language&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt; &lt;br /&gt;
  &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files are saved to the core language folder in the traditional way.&lt;br /&gt;
Only the files for installed languages are copied.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125228</id>
		<title>User:Over/Step by step to a Joomla Module - Installation package</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125228"/>
		<updated>2014-09-06T02:00:20Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Alternative language files  handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to become an installable extension for any Joomla! 3.x site. e.g. after testing the functionality on your local installation you can upload and install it on your live site with a few clicks.&lt;br /&gt;
&lt;br /&gt;
=== Language files ===&lt;br /&gt;
&lt;br /&gt;
The language files hold the textstrings that are used for descriptions, field labels, field descriptions and any other static texts. You can also translate the textstrings for any language code. The default language code is en-GB, Great Britain english. In version 3 the english &amp;quot;translation&amp;quot; is in most cases loaded before any other specific language. i.e. you should always keep those files up to date.&lt;br /&gt;
&lt;br /&gt;
As in the first part of the tutorial we&#039;ll use skeleton files. In the folder, where you unzipped the downloaded file, you can find two language files, en-GB.mod_yourmodule.ini and en-GB.mod_yourmodule.sys.ini Copy those to the Joomla! en-GB language folder. path/to/joomla/language/en-GB. You can also find a language folder in the administrator/ path used for backend extensions and all plug ins.&lt;br /&gt;
&lt;br /&gt;
As always, change files named ...yourmodule... to the name you did choose. Open the first file en-GB.mod_yourmodule.ini&lt;br /&gt;
&lt;br /&gt;
===== en-GB.mod_yourmodule.ini =====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Copyright (C) 2014 Joomla Doe&lt;br /&gt;
; Translater Joomla Doe&lt;br /&gt;
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php&lt;br /&gt;
; Note : All ini files need to be saved as UTF-8 - No BOM&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE=&amp;quot;Your own module&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of my module. This one in .ini is shown when editing the module in the Module Manager. Yoü can e.g. add some tips to the confuguration and a link to a help page on your site&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the top we find some comments. As you see, you have to use ; in front of the comments. If you have friendly helpers that translate your extension, it&#039;s nice to have a line with the translators name. The use of character set UTF-8 is noted. For the language string constants you should follow the Joomla! best practice i.e. start all language constants with the extension name. &#039;&#039;&#039;The language constants have to be in upper case with _ (underscore) as divider ending with a =. The text has to be within &amp;quot; double quote.&#039;&#039;&#039; Do not use double quote within the text or you will have to find out how to use __QQ__. &#039;&#039;&#039;No line break is allowed!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
; An example with double quote&lt;br /&gt;
MOD_YOURMODULE_MY_QUOTE=&amp;quot;My value is &amp;quot;_QQ_&amp;quot;great!&amp;quot;_QQ_&amp;quot;. I like it&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is no good reference available at the time of writing. Please change this link if a better is found. [[Specification_of_language_files|Specification of language files]]&lt;br /&gt;
&lt;br /&gt;
Change the two MOD_YOURMODULE, change the first text to a &amp;quot;human&amp;quot; name of your module and change the description. Again: in one line! &#039;&#039;&#039;no line break is allowed!&#039;&#039;&#039;. If you add e.g. a link remeber &amp;quot;_QQ_&amp;quot; for double quotes. Save this file and copy the text except the description content. The second file has almost the same content at this stage. Open en-GB.mod_yourmodule.sys.ini and paste the copied text replacing the text i.e. not the description text.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of your module. This one in .sys.ini is shown when choosing a new module in the module manager and in the extension manager. Keep this shorter.&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the description and save.&lt;br /&gt;
&lt;br /&gt;
The difference between those is that the .sys.ini file is loaded in cases like module lists where no module fields are shown. We´ll see another use of the .sys.ini below.&lt;br /&gt;
&lt;br /&gt;
As promised in the first part of the tutorial, you can now see the reason for using mod_yourmodule as module name in the xml file. Go to Module Manager, click on new. You will find your module with the name from the language file. Next we will fix the description. Before you close the files copy the constant MOD_YOURMODULE_XML_DESCRIPTION-&lt;br /&gt;
&lt;br /&gt;
Open mod_yourmodule.xml from the server and find the description line. Replace the description with your copied language constant MOD_YOURMODULE_XML_DESCRIPTION.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Description ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;MOD_YOURMODULE_XML_DESCRIPTION&amp;lt;/description&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can make the same test as before in the Module Manager and you&#039;ll see that the description comes from the language files.&lt;br /&gt;
&lt;br /&gt;
=== Parameters - Options ===&lt;br /&gt;
If you choose your enabled module for edit in the Module Manager you&#039;ll se some default options under the advanced tab. Let&#039;s add some more options in the xml file and add the used language strings before we create the first installable package.&lt;br /&gt;
&lt;br /&gt;
Add the following where you find the config part. We will see more around form fields in a later tutorial part.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Config ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;config&amp;gt;&lt;br /&gt;
      &amp;lt;fields name=&amp;quot;params&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;options&amp;quot; label=&amp;quot;COM_MODULES_BASIC_FIELDSET_LABEL&amp;quot;&lt;br /&gt;
            addfieldpath=&amp;quot;/administrator/components/com_content/models/fields/modal&amp;quot;&lt;br /&gt;
	 &amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;article_id&amp;quot;&lt;br /&gt;
               type=&amp;quot;modal_article&amp;quot;&lt;br /&gt;
               default=&amp;quot;&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_DESC&amp;quot; &amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;advanced&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_css&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_js&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;layout&amp;quot;&lt;br /&gt;
               type=&amp;quot;modulelayout&amp;quot;&lt;br /&gt;
               label=&amp;quot;JFIELD_ALT_LAYOUT_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;JFIELD_ALT_MODULE_LAYOUT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;moduleclass_sfx&amp;quot;&lt;br /&gt;
               type=&amp;quot;textarea&amp;quot; rows=&amp;quot;3&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache&amp;quot;&lt;br /&gt;
               type=&amp;quot;list&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHING_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHING_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JGLOBAL_USE_GLOBAL&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;COM_MODULES_FIELD_VALUE_NOCACHING&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache_time&amp;quot;&lt;br /&gt;
               type=&amp;quot;text&amp;quot;&lt;br /&gt;
               default=&amp;quot;900&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cachemode&amp;quot;&lt;br /&gt;
               type=&amp;quot;hidden&amp;quot;&lt;br /&gt;
               default=&amp;quot;static&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;static&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
      &amp;lt;/fields&amp;gt;&lt;br /&gt;
   &amp;lt;/config&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the fieldset options we add an option field &amp;quot;article_id&amp;quot; that we will use later. This field calls a modal window where you can choose an article. Fieldset options is shown in the tab Options in the Module Manager. If you use a fieldset named basic you&#039;ll have those fields in the first tab. We also add some standard option fields to the &amp;quot;Advanced&amp;quot; tab. We do not have to add the text constants used in the Advanced part since they are standard. Remains the two strings used for the article field. Well, we added two fields in the advanced tab, load_css and load_js with language strings that need to be added. We&#039;ll come back to the use of those options later. &lt;br /&gt;
&lt;br /&gt;
Follow this link to read more about [http://docs.joomla.org/Module Joomla modules and the Modules Manager]&lt;br /&gt;
&lt;br /&gt;
=== Add strings to language file ===&lt;br /&gt;
Save the xml file and open the language file. The one without .sys.&lt;br /&gt;
&lt;br /&gt;
Add the 6 strings and save.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.ini - New strings ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_DESC=&amp;quot;Choose an article to be shown by the module.&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_LABEL=&amp;quot;Article&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_DESC=&amp;quot;You can disable the modules css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL=&amp;quot;Load Css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_DESC=&amp;quot;You can disable the modules JavaScript&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_LABEL=&amp;quot;Load JavaScript&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Final change to the xml file ===&lt;br /&gt;
&lt;br /&gt;
Before we create the first installation file we will add the language tags to the xml file below the &amp;lt;/files&amp;gt; tag.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Final ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
   &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We use a folder named langs here, because we will use the folder language for a trick. If you include other language files just add lines with the correspondent language identifier.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;large-12 panel radius&amp;quot; style=&amp;quot;background-color:#fff; border:1px solid #aaa; margin:1em 0;&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;For those of you that have some knowledge of Joomla development:&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
Do not add the /language folder to the xml file. It is autoloaded. i.e. extracted and used in the installation process by default.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the xml file.&lt;br /&gt;
&lt;br /&gt;
=== Create the compressed installation file ===&lt;br /&gt;
Now we have everything to create the first version of the installation file.&lt;br /&gt;
&lt;br /&gt;
Inside the folder you created on yor local system at the start of the tutorial &#039;somewhere&#039;/j_module_tutorial/new_module you add three sub directories. langs, language and tmpl. Now you copy the files in the other direction. From the web directory to the new one. It should look something like this ( remember - yourmodule - is a placeholder for your choosen module name ):&lt;br /&gt;
&lt;br /&gt;
* .../new_module&lt;br /&gt;
** .../new_module/langs&lt;br /&gt;
*** en-GB.mod_yourmodule.ini&lt;br /&gt;
*** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
*** anyother-language.mod_yourmodule.in&lt;br /&gt;
*** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
** .../new_module/language&lt;br /&gt;
*** .../new_module/language/en-GB&lt;br /&gt;
**** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
*** .../new_module/language/anyother-language&lt;br /&gt;
**** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
** .../new_module/tmpl&lt;br /&gt;
*** default.php&lt;br /&gt;
** mod_yourmodule.php&lt;br /&gt;
** mod_yourmodule.xml&lt;br /&gt;
&lt;br /&gt;
As a last step we&#039;ll edit the .../new_module/language/en-GB/mod_yourmodule.sys.ini to show a different message at installation/upgrade.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.sys.ini - Installation message ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;Thank you for installing / update the Your own module. This module displays an article text in a module position. To activate you go to the module manager and edit this module or create a new entry. Select the article you want to show. Please visit www.mysite.com for more information. If you like it please add a review on JED.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you edit the description text to include a &amp;quot;Thanks&amp;quot; and other informations only relevant directly after the installation / upgrade this is a trick to achieve this. Only .../new_module/langs/mod_yourmodule.sys.ini will be copied and used after the installation.&lt;br /&gt;
&lt;br /&gt;
You can find two short descriptions of alternative handling of the language files at the end of this page.&lt;br /&gt;
&lt;br /&gt;
Now we compress the files. The Zip type is recommended as it has native support by most systems. In Windows you go to the .../new_module folder. Mark the included folders and files, right click and choose {{rarr|Send to,ZIP compressed folder}}.&lt;br /&gt;
&lt;br /&gt;
Rename the .zip file to mod_yourmodule_1_0_0.zip i.e. including the version number. You should better move this file to another folder. It is easy forgotten NOT to include it, the next time you create a zipped file.&lt;br /&gt;
&lt;br /&gt;
You made a backup before starting the tutorial? Well, only in case of ...&lt;br /&gt;
&lt;br /&gt;
First you uninstall the module to get a complete new installation {{rarr|Extensions,Manager,Manage}} Look up the module. Filter e.g. Location = Site, Type=Module and/or name.&lt;br /&gt;
&lt;br /&gt;
When the module is uninstalled you go to Install, browse to your installation zip file and click the Upload &amp;amp;amp; Install button. You&#039;ll see the description you edited as installation message. Go to the Module Manager. This time you should find an entry in the Module list. Choose this and enable it, as you did after the Discover in the first part of the tutorial. You can also see that the description is the one from your .ini file. To check the description from .sys.ini click on NEW module. This is not the one you saw directly after the installation.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this part of the module tutorial. The next part will show you how to retrieve data and add some Css styling to your module.&lt;br /&gt;
&lt;br /&gt;
=== Alternative language files  handling ===&lt;br /&gt;
&lt;br /&gt;
For both alternatives you have to add all language files to subfolders in the /language folder. Be aware that the folder name is mandatory! &lt;br /&gt;
&lt;br /&gt;
You can use the language files from the /langs folder in the example above. Do not add a long description to the .sys.ini files, as it will be used for the module lists. Of course you have to remove the /langs folder, if you want to test by changing the example above.&lt;br /&gt;
&lt;br /&gt;
Resulting folder:&lt;br /&gt;
&lt;br /&gt;
* /language&lt;br /&gt;
** /en-GB&lt;br /&gt;
*** en-GB.mod_yourmodule.ini&lt;br /&gt;
*** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
** /anyother-language&lt;br /&gt;
*** anyother-language.mod_yourmodule.ini&lt;br /&gt;
*** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
&lt;br /&gt;
==== 1. Easiest way  ====&lt;br /&gt;
&lt;br /&gt;
Add a folder tag to the files area in the xml file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;folder&amp;gt;language&amp;lt;/folder&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The folder will be stored in the extensions folder and no files in the core language folder.&lt;br /&gt;
ALL files are copied, not only the ones for installed languages.&lt;br /&gt;
&lt;br /&gt;
==== 2. Traditional way  ====&lt;br /&gt;
&lt;br /&gt;
Add all single language files to the languages tag in the xml file. Be aware of the extra folder name required (= language tag).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;language&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt; &lt;br /&gt;
  &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files are saved to the core language folder in the traditional way.&lt;br /&gt;
Only the files for installed languages are copied.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125227</id>
		<title>User:Over/Step by step to a Joomla Module - Installation package</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125227"/>
		<updated>2014-09-06T01:51:25Z</updated>

		<summary type="html">&lt;p&gt;Over: /* 2. Traditional way */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to become an installable extension for any Joomla! 3.x site. e.g. after testing the functionality on your local installation you can upload and install it on your live site with a few clicks.&lt;br /&gt;
&lt;br /&gt;
=== Language files ===&lt;br /&gt;
&lt;br /&gt;
The language files hold the textstrings that are used for descriptions, field labels, field descriptions and any other static texts. You can also translate the textstrings for any language code. The default language code is en-GB, Great Britain english. In version 3 the english &amp;quot;translation&amp;quot; is in most cases loaded before any other specific language. i.e. you should always keep those files up to date.&lt;br /&gt;
&lt;br /&gt;
As in the first part of the tutorial we&#039;ll use skeleton files. In the folder, where you unzipped the downloaded file, you can find two language files, en-GB.mod_yourmodule.ini and en-GB.mod_yourmodule.sys.ini Copy those to the Joomla! en-GB language folder. path/to/joomla/language/en-GB. You can also find a language folder in the administrator/ path used for backend extensions and all plug ins.&lt;br /&gt;
&lt;br /&gt;
As always, change files named ...yourmodule... to the name you did choose. Open the first file en-GB.mod_yourmodule.ini&lt;br /&gt;
&lt;br /&gt;
===== en-GB.mod_yourmodule.ini =====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Copyright (C) 2014 Joomla Doe&lt;br /&gt;
; Translater Joomla Doe&lt;br /&gt;
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php&lt;br /&gt;
; Note : All ini files need to be saved as UTF-8 - No BOM&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE=&amp;quot;Your own module&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of my module. This one in .ini is shown when editing the module in the Module Manager. Yoü can e.g. add some tips to the confuguration and a link to a help page on your site&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the top we find some comments. As you see, you have to use ; in front of the comments. If you have friendly helpers that translate your extension, it&#039;s nice to have a line with the translators name. The use of character set UTF-8 is noted. For the language string constants you should follow the Joomla! best practice i.e. start all language constants with the extension name. &#039;&#039;&#039;The language constants have to be in upper case with _ (underscore) as divider ending with a =. The text has to be within &amp;quot; double quote.&#039;&#039;&#039; Do not use double quote within the text or you will have to find out how to use __QQ__. &#039;&#039;&#039;No line break is allowed!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
; An example with double quote&lt;br /&gt;
MOD_YOURMODULE_MY_QUOTE=&amp;quot;My value is &amp;quot;_QQ_&amp;quot;great!&amp;quot;_QQ_&amp;quot;. I like it&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is no good reference available at the time of writing. Please change this link if a better is found. [[Specification_of_language_files|Specification of language files]]&lt;br /&gt;
&lt;br /&gt;
Change the two MOD_YOURMODULE, change the first text to a &amp;quot;human&amp;quot; name of your module and change the description. Again: in one line! &#039;&#039;&#039;no line break is allowed!&#039;&#039;&#039;. If you add e.g. a link remeber &amp;quot;_QQ_&amp;quot; for double quotes. Save this file and copy the text except the description content. The second file has almost the same content at this stage. Open en-GB.mod_yourmodule.sys.ini and paste the copied text replacing the text i.e. not the description text.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of your module. This one in .sys.ini is shown when choosing a new module in the module manager and in the extension manager. Keep this shorter.&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the description and save.&lt;br /&gt;
&lt;br /&gt;
The difference between those is that the .sys.ini file is loaded in cases like module lists where no module fields are shown. We´ll see another use of the .sys.ini below.&lt;br /&gt;
&lt;br /&gt;
As promised in the first part of the tutorial, you can now see the reason for using mod_yourmodule as module name in the xml file. Go to Module Manager, click on new. You will find your module with the name from the language file. Next we will fix the description. Before you close the files copy the constant MOD_YOURMODULE_XML_DESCRIPTION-&lt;br /&gt;
&lt;br /&gt;
Open mod_yourmodule.xml from the server and find the description line. Replace the description with your copied language constant MOD_YOURMODULE_XML_DESCRIPTION.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Description ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;MOD_YOURMODULE_XML_DESCRIPTION&amp;lt;/description&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can make the same test as before in the Module Manager and you&#039;ll see that the description comes from the language files.&lt;br /&gt;
&lt;br /&gt;
=== Parameters - Options ===&lt;br /&gt;
If you choose your enabled module for edit in the Module Manager you&#039;ll se some default options under the advanced tab. Let&#039;s add some more options in the xml file and add the used language strings before we create the first installable package.&lt;br /&gt;
&lt;br /&gt;
Add the following where you find the config part. We will see more around form fields in a later tutorial part.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Config ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;config&amp;gt;&lt;br /&gt;
      &amp;lt;fields name=&amp;quot;params&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;options&amp;quot; label=&amp;quot;COM_MODULES_BASIC_FIELDSET_LABEL&amp;quot;&lt;br /&gt;
            addfieldpath=&amp;quot;/administrator/components/com_content/models/fields/modal&amp;quot;&lt;br /&gt;
	 &amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;article_id&amp;quot;&lt;br /&gt;
               type=&amp;quot;modal_article&amp;quot;&lt;br /&gt;
               default=&amp;quot;&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_DESC&amp;quot; &amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;advanced&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_css&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_js&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;layout&amp;quot;&lt;br /&gt;
               type=&amp;quot;modulelayout&amp;quot;&lt;br /&gt;
               label=&amp;quot;JFIELD_ALT_LAYOUT_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;JFIELD_ALT_MODULE_LAYOUT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;moduleclass_sfx&amp;quot;&lt;br /&gt;
               type=&amp;quot;textarea&amp;quot; rows=&amp;quot;3&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache&amp;quot;&lt;br /&gt;
               type=&amp;quot;list&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHING_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHING_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JGLOBAL_USE_GLOBAL&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;COM_MODULES_FIELD_VALUE_NOCACHING&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache_time&amp;quot;&lt;br /&gt;
               type=&amp;quot;text&amp;quot;&lt;br /&gt;
               default=&amp;quot;900&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cachemode&amp;quot;&lt;br /&gt;
               type=&amp;quot;hidden&amp;quot;&lt;br /&gt;
               default=&amp;quot;static&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;static&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
      &amp;lt;/fields&amp;gt;&lt;br /&gt;
   &amp;lt;/config&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the fieldset options we add an option field &amp;quot;article_id&amp;quot; that we will use later. This field calls a modal window where you can choose an article. Fieldset options is shown in the tab Options in the Module Manager. If you use a fieldset named basic you&#039;ll have those fields in the first tab. We also add some standard option fields to the &amp;quot;Advanced&amp;quot; tab. We do not have to add the text constants used in the Advanced part since they are standard. Remains the two strings used for the article field. Well, we added two fields in the advanced tab, load_css and load_js with language strings that need to be added. We&#039;ll come back to the use of those options later. &lt;br /&gt;
&lt;br /&gt;
Follow this link to read more about [http://docs.joomla.org/Module Joomla modules and the Modules Manager]&lt;br /&gt;
&lt;br /&gt;
=== Add strings to language file ===&lt;br /&gt;
Save the xml file and open the language file. The one without .sys.&lt;br /&gt;
&lt;br /&gt;
Add the 6 strings and save.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.ini - New strings ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_DESC=&amp;quot;Choose an article to be shown by the module.&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_LABEL=&amp;quot;Article&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_DESC=&amp;quot;You can disable the modules css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL=&amp;quot;Load Css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_DESC=&amp;quot;You can disable the modules JavaScript&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_LABEL=&amp;quot;Load JavaScript&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Final change to the xml file ===&lt;br /&gt;
&lt;br /&gt;
Before we create the first installation file we will add the language tags to the xml file below the &amp;lt;/files&amp;gt; tag.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Final ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
   &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We use a folder named langs here, because we will use the folder language for a trick. If you include other language files just add lines with the correspondent language identifier.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;large-12 panel radius&amp;quot; style=&amp;quot;background-color:#fff; border:1px solid #aaa; margin:1em 0;&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;For those of you that have some knowledge of Joomla development:&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
Do not add the /language folder to the xml file. It is autoloaded. i.e. extracted and used in the installation process by default.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the xml file.&lt;br /&gt;
&lt;br /&gt;
=== Create the compressed installation file ===&lt;br /&gt;
Now we have everything to create the first version of the installation file.&lt;br /&gt;
&lt;br /&gt;
Inside the folder you created on yor local system at the start of the tutorial &#039;somewhere&#039;/j_module_tutorial/new_module you add three sub directories. langs, language and tmpl. Now you copy the files in the other direction. From the web directory to the new one. It should look something like this ( remember - yourmodule - is a placeholder for your choosen module name ):&lt;br /&gt;
&lt;br /&gt;
* .../new_module&lt;br /&gt;
** .../new_module/langs&lt;br /&gt;
*** en-GB.mod_yourmodule.ini&lt;br /&gt;
*** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
*** anyother-language.mod_yourmodule.in&lt;br /&gt;
*** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
** .../new_module/language&lt;br /&gt;
*** .../new_module/language/en-GB&lt;br /&gt;
**** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
*** .../new_module/language/anyother-language&lt;br /&gt;
**** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
** .../new_module/tmpl&lt;br /&gt;
*** default.php&lt;br /&gt;
** mod_yourmodule.php&lt;br /&gt;
** mod_yourmodule.xml&lt;br /&gt;
&lt;br /&gt;
As a last step we&#039;ll edit the .../new_module/language/en-GB/mod_yourmodule.sys.ini to show a different message at installation/upgrade.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.sys.ini - Installation message ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;Thank you for installing / update the Your own module. This module displays an article text in a module position. To activate you go to the module manager and edit this module or create a new entry. Select the article you want to show. Please visit www.mysite.com for more information. If you like it please add a review on JED.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you edit the description text to include a &amp;quot;Thanks&amp;quot; and other informations only relevant directly after the installation / upgrade this is a trick to achieve this. Only .../new_module/langs/mod_yourmodule.sys.ini will be copied and used after the installation.&lt;br /&gt;
&lt;br /&gt;
You can find two short descriptions of alternative handling of the language files at the end of this page.&lt;br /&gt;
&lt;br /&gt;
Now we compress the files. The Zip type is recommended as it has native support by most systems. In Windows you go to the .../new_module folder. Mark the included folders and files, right click and choose {{rarr|Send to,ZIP compressed folder}}.&lt;br /&gt;
&lt;br /&gt;
Rename the .zip file to mod_yourmodule_1_0_0.zip i.e. including the version number. You should better move this file to another folder. It is easy forgotten NOT to include it, the next time you create a zipped file.&lt;br /&gt;
&lt;br /&gt;
You made a backup before starting the tutorial? Well, only in case of ...&lt;br /&gt;
&lt;br /&gt;
First you uninstall the module to get a complete new installation {{rarr|Extensions,Manager,Manage}} Look up the module. Filter e.g. Location = Site, Type=Module and/or name.&lt;br /&gt;
&lt;br /&gt;
When the module is uninstalled you go to Install, browse to your installation zip file and click the Upload &amp;amp;amp; Install button. You&#039;ll see the description you edited as installation message. Go to the Module Manager. This time you should find an entry in the Module list. Choose this and enable it, as you did after the Discover in the first part of the tutorial. You can also see that the description is the one from your .ini file. To check the description from .sys.ini click on NEW module. This is not the one you saw directly after the installation.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this part of the module tutorial. The next part will show you how to retrieve data and add some Css styling to your module.&lt;br /&gt;
&lt;br /&gt;
=== Alternative language files  handling ===&lt;br /&gt;
&lt;br /&gt;
For both alternatives you have to add all language files to subfolders in the /language folder. Be aware that the folder name is mandatory! &lt;br /&gt;
&lt;br /&gt;
You can use the language files from the /langs folder in the example above. Do not add a long description to the .sys.ini files, as it will be used for the module lists. Of course you have to remove the /langs folder, if you want to test by changing the example above.&lt;br /&gt;
&lt;br /&gt;
Resulting folder:&lt;br /&gt;
&lt;br /&gt;
* /language&lt;br /&gt;
**/language/en-GB&lt;br /&gt;
*** en-GB.mod_yourmodule.ini&lt;br /&gt;
*** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
** /language/anyother-language&lt;br /&gt;
*** anyother-language.mod_yourmodule.ini&lt;br /&gt;
*** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
&lt;br /&gt;
==== 1. Easiest way  ====&lt;br /&gt;
&lt;br /&gt;
Add a folder tag to the files area in the xml file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;folder&amp;gt;language&amp;lt;/folder&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The folder will be stored in the extensions folder and no files in the core language folder.&lt;br /&gt;
ALL files are copied, not only the ones for installed languages.&lt;br /&gt;
&lt;br /&gt;
==== 2. Traditional way  ====&lt;br /&gt;
&lt;br /&gt;
Add all single language files to the languages tag in the xml file. Be aware of the extra folder name required (= language tag).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;language&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt; &lt;br /&gt;
  &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files are saved to the core language folder in the traditional way.&lt;br /&gt;
Only the files for installed languages are copied.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125226</id>
		<title>User:Over/Step by step to a Joomla Module - Installation package</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125226"/>
		<updated>2014-09-06T01:48:43Z</updated>

		<summary type="html">&lt;p&gt;Over: /* 1. Easiest way */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to become an installable extension for any Joomla! 3.x site. e.g. after testing the functionality on your local installation you can upload and install it on your live site with a few clicks.&lt;br /&gt;
&lt;br /&gt;
=== Language files ===&lt;br /&gt;
&lt;br /&gt;
The language files hold the textstrings that are used for descriptions, field labels, field descriptions and any other static texts. You can also translate the textstrings for any language code. The default language code is en-GB, Great Britain english. In version 3 the english &amp;quot;translation&amp;quot; is in most cases loaded before any other specific language. i.e. you should always keep those files up to date.&lt;br /&gt;
&lt;br /&gt;
As in the first part of the tutorial we&#039;ll use skeleton files. In the folder, where you unzipped the downloaded file, you can find two language files, en-GB.mod_yourmodule.ini and en-GB.mod_yourmodule.sys.ini Copy those to the Joomla! en-GB language folder. path/to/joomla/language/en-GB. You can also find a language folder in the administrator/ path used for backend extensions and all plug ins.&lt;br /&gt;
&lt;br /&gt;
As always, change files named ...yourmodule... to the name you did choose. Open the first file en-GB.mod_yourmodule.ini&lt;br /&gt;
&lt;br /&gt;
===== en-GB.mod_yourmodule.ini =====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Copyright (C) 2014 Joomla Doe&lt;br /&gt;
; Translater Joomla Doe&lt;br /&gt;
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php&lt;br /&gt;
; Note : All ini files need to be saved as UTF-8 - No BOM&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE=&amp;quot;Your own module&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of my module. This one in .ini is shown when editing the module in the Module Manager. Yoü can e.g. add some tips to the confuguration and a link to a help page on your site&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the top we find some comments. As you see, you have to use ; in front of the comments. If you have friendly helpers that translate your extension, it&#039;s nice to have a line with the translators name. The use of character set UTF-8 is noted. For the language string constants you should follow the Joomla! best practice i.e. start all language constants with the extension name. &#039;&#039;&#039;The language constants have to be in upper case with _ (underscore) as divider ending with a =. The text has to be within &amp;quot; double quote.&#039;&#039;&#039; Do not use double quote within the text or you will have to find out how to use __QQ__. &#039;&#039;&#039;No line break is allowed!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
; An example with double quote&lt;br /&gt;
MOD_YOURMODULE_MY_QUOTE=&amp;quot;My value is &amp;quot;_QQ_&amp;quot;great!&amp;quot;_QQ_&amp;quot;. I like it&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is no good reference available at the time of writing. Please change this link if a better is found. [[Specification_of_language_files|Specification of language files]]&lt;br /&gt;
&lt;br /&gt;
Change the two MOD_YOURMODULE, change the first text to a &amp;quot;human&amp;quot; name of your module and change the description. Again: in one line! &#039;&#039;&#039;no line break is allowed!&#039;&#039;&#039;. If you add e.g. a link remeber &amp;quot;_QQ_&amp;quot; for double quotes. Save this file and copy the text except the description content. The second file has almost the same content at this stage. Open en-GB.mod_yourmodule.sys.ini and paste the copied text replacing the text i.e. not the description text.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of your module. This one in .sys.ini is shown when choosing a new module in the module manager and in the extension manager. Keep this shorter.&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the description and save.&lt;br /&gt;
&lt;br /&gt;
The difference between those is that the .sys.ini file is loaded in cases like module lists where no module fields are shown. We´ll see another use of the .sys.ini below.&lt;br /&gt;
&lt;br /&gt;
As promised in the first part of the tutorial, you can now see the reason for using mod_yourmodule as module name in the xml file. Go to Module Manager, click on new. You will find your module with the name from the language file. Next we will fix the description. Before you close the files copy the constant MOD_YOURMODULE_XML_DESCRIPTION-&lt;br /&gt;
&lt;br /&gt;
Open mod_yourmodule.xml from the server and find the description line. Replace the description with your copied language constant MOD_YOURMODULE_XML_DESCRIPTION.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Description ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;MOD_YOURMODULE_XML_DESCRIPTION&amp;lt;/description&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can make the same test as before in the Module Manager and you&#039;ll see that the description comes from the language files.&lt;br /&gt;
&lt;br /&gt;
=== Parameters - Options ===&lt;br /&gt;
If you choose your enabled module for edit in the Module Manager you&#039;ll se some default options under the advanced tab. Let&#039;s add some more options in the xml file and add the used language strings before we create the first installable package.&lt;br /&gt;
&lt;br /&gt;
Add the following where you find the config part. We will see more around form fields in a later tutorial part.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Config ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;config&amp;gt;&lt;br /&gt;
      &amp;lt;fields name=&amp;quot;params&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;options&amp;quot; label=&amp;quot;COM_MODULES_BASIC_FIELDSET_LABEL&amp;quot;&lt;br /&gt;
            addfieldpath=&amp;quot;/administrator/components/com_content/models/fields/modal&amp;quot;&lt;br /&gt;
	 &amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;article_id&amp;quot;&lt;br /&gt;
               type=&amp;quot;modal_article&amp;quot;&lt;br /&gt;
               default=&amp;quot;&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_DESC&amp;quot; &amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;advanced&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_css&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_js&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;layout&amp;quot;&lt;br /&gt;
               type=&amp;quot;modulelayout&amp;quot;&lt;br /&gt;
               label=&amp;quot;JFIELD_ALT_LAYOUT_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;JFIELD_ALT_MODULE_LAYOUT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;moduleclass_sfx&amp;quot;&lt;br /&gt;
               type=&amp;quot;textarea&amp;quot; rows=&amp;quot;3&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache&amp;quot;&lt;br /&gt;
               type=&amp;quot;list&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHING_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHING_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JGLOBAL_USE_GLOBAL&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;COM_MODULES_FIELD_VALUE_NOCACHING&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache_time&amp;quot;&lt;br /&gt;
               type=&amp;quot;text&amp;quot;&lt;br /&gt;
               default=&amp;quot;900&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cachemode&amp;quot;&lt;br /&gt;
               type=&amp;quot;hidden&amp;quot;&lt;br /&gt;
               default=&amp;quot;static&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;static&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
      &amp;lt;/fields&amp;gt;&lt;br /&gt;
   &amp;lt;/config&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the fieldset options we add an option field &amp;quot;article_id&amp;quot; that we will use later. This field calls a modal window where you can choose an article. Fieldset options is shown in the tab Options in the Module Manager. If you use a fieldset named basic you&#039;ll have those fields in the first tab. We also add some standard option fields to the &amp;quot;Advanced&amp;quot; tab. We do not have to add the text constants used in the Advanced part since they are standard. Remains the two strings used for the article field. Well, we added two fields in the advanced tab, load_css and load_js with language strings that need to be added. We&#039;ll come back to the use of those options later. &lt;br /&gt;
&lt;br /&gt;
Follow this link to read more about [http://docs.joomla.org/Module Joomla modules and the Modules Manager]&lt;br /&gt;
&lt;br /&gt;
=== Add strings to language file ===&lt;br /&gt;
Save the xml file and open the language file. The one without .sys.&lt;br /&gt;
&lt;br /&gt;
Add the 6 strings and save.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.ini - New strings ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_DESC=&amp;quot;Choose an article to be shown by the module.&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_LABEL=&amp;quot;Article&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_DESC=&amp;quot;You can disable the modules css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL=&amp;quot;Load Css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_DESC=&amp;quot;You can disable the modules JavaScript&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_LABEL=&amp;quot;Load JavaScript&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Final change to the xml file ===&lt;br /&gt;
&lt;br /&gt;
Before we create the first installation file we will add the language tags to the xml file below the &amp;lt;/files&amp;gt; tag.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Final ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
   &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We use a folder named langs here, because we will use the folder language for a trick. If you include other language files just add lines with the correspondent language identifier.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;large-12 panel radius&amp;quot; style=&amp;quot;background-color:#fff; border:1px solid #aaa; margin:1em 0;&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;For those of you that have some knowledge of Joomla development:&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
Do not add the /language folder to the xml file. It is autoloaded. i.e. extracted and used in the installation process by default.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the xml file.&lt;br /&gt;
&lt;br /&gt;
=== Create the compressed installation file ===&lt;br /&gt;
Now we have everything to create the first version of the installation file.&lt;br /&gt;
&lt;br /&gt;
Inside the folder you created on yor local system at the start of the tutorial &#039;somewhere&#039;/j_module_tutorial/new_module you add three sub directories. langs, language and tmpl. Now you copy the files in the other direction. From the web directory to the new one. It should look something like this ( remember - yourmodule - is a placeholder for your choosen module name ):&lt;br /&gt;
&lt;br /&gt;
* .../new_module&lt;br /&gt;
** .../new_module/langs&lt;br /&gt;
*** en-GB.mod_yourmodule.ini&lt;br /&gt;
*** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
*** anyother-language.mod_yourmodule.in&lt;br /&gt;
*** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
** .../new_module/language&lt;br /&gt;
*** .../new_module/language/en-GB&lt;br /&gt;
**** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
*** .../new_module/language/anyother-language&lt;br /&gt;
**** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
** .../new_module/tmpl&lt;br /&gt;
*** default.php&lt;br /&gt;
** mod_yourmodule.php&lt;br /&gt;
** mod_yourmodule.xml&lt;br /&gt;
&lt;br /&gt;
As a last step we&#039;ll edit the .../new_module/language/en-GB/mod_yourmodule.sys.ini to show a different message at installation/upgrade.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.sys.ini - Installation message ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;Thank you for installing / update the Your own module. This module displays an article text in a module position. To activate you go to the module manager and edit this module or create a new entry. Select the article you want to show. Please visit www.mysite.com for more information. If you like it please add a review on JED.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you edit the description text to include a &amp;quot;Thanks&amp;quot; and other informations only relevant directly after the installation / upgrade this is a trick to achieve this. Only .../new_module/langs/mod_yourmodule.sys.ini will be copied and used after the installation.&lt;br /&gt;
&lt;br /&gt;
You can find two short descriptions of alternative handling of the language files at the end of this page.&lt;br /&gt;
&lt;br /&gt;
Now we compress the files. The Zip type is recommended as it has native support by most systems. In Windows you go to the .../new_module folder. Mark the included folders and files, right click and choose {{rarr|Send to,ZIP compressed folder}}.&lt;br /&gt;
&lt;br /&gt;
Rename the .zip file to mod_yourmodule_1_0_0.zip i.e. including the version number. You should better move this file to another folder. It is easy forgotten NOT to include it, the next time you create a zipped file.&lt;br /&gt;
&lt;br /&gt;
You made a backup before starting the tutorial? Well, only in case of ...&lt;br /&gt;
&lt;br /&gt;
First you uninstall the module to get a complete new installation {{rarr|Extensions,Manager,Manage}} Look up the module. Filter e.g. Location = Site, Type=Module and/or name.&lt;br /&gt;
&lt;br /&gt;
When the module is uninstalled you go to Install, browse to your installation zip file and click the Upload &amp;amp;amp; Install button. You&#039;ll see the description you edited as installation message. Go to the Module Manager. This time you should find an entry in the Module list. Choose this and enable it, as you did after the Discover in the first part of the tutorial. You can also see that the description is the one from your .ini file. To check the description from .sys.ini click on NEW module. This is not the one you saw directly after the installation.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this part of the module tutorial. The next part will show you how to retrieve data and add some Css styling to your module.&lt;br /&gt;
&lt;br /&gt;
=== Alternative language files  handling ===&lt;br /&gt;
&lt;br /&gt;
For both alternatives you have to add all language files to subfolders in the /language folder. Be aware that the folder name is mandatory! &lt;br /&gt;
&lt;br /&gt;
You can use the language files from the /langs folder in the example above. Do not add a long description to the .sys.ini files, as it will be used for the module lists. Of course you have to remove the /langs folder, if you want to test by changing the example above.&lt;br /&gt;
&lt;br /&gt;
Resulting folder:&lt;br /&gt;
&lt;br /&gt;
* /language&lt;br /&gt;
**/language/en-GB&lt;br /&gt;
*** en-GB.mod_yourmodule.ini&lt;br /&gt;
*** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
** /language/anyother-language&lt;br /&gt;
*** anyother-language.mod_yourmodule.ini&lt;br /&gt;
*** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
&lt;br /&gt;
==== 1. Easiest way  ====&lt;br /&gt;
&lt;br /&gt;
Add a folder tag to the files area in the xml file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;folder&amp;gt;language&amp;lt;/folder&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The folder will be stored in the extensions folder and no files in the core language folder.&lt;br /&gt;
ALL files are copied, not only the ones for installed languages.&lt;br /&gt;
&lt;br /&gt;
==== 2. Traditional way  ====&lt;br /&gt;
&lt;br /&gt;
Add all single language files to the languages tag in the xml file. Be aware of the extra folder name required (= language tag).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;language&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt; &lt;br /&gt;
  &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files are saved to the core language folder in the traditional way.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Overrides&amp;diff=125225</id>
		<title>User:Over/Step by step to a Joomla Module - Overrides</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Overrides&amp;diff=125225"/>
		<updated>2014-09-05T12:38:53Z</updated>

		<summary type="html">&lt;p&gt;Over: /* The html/layouts path */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
In this step we&#039;ll use your custom module to show you how you can use the powerful Joomla! methods to override ( = change ) the output. The same possibilities are valid for all modules and components that follows the Joomla! best practice.&lt;br /&gt;
&lt;br /&gt;
=== Your site template directory ===&lt;br /&gt;
&lt;br /&gt;
As you probably know, your template is found under the templates/ folder in your Joomla! directory. The folders important for our overrides are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
/templates&lt;br /&gt;
  ...&lt;br /&gt;
  /mytemplate&lt;br /&gt;
    /css&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule.css&lt;br /&gt;
      ...&lt;br /&gt;
    /html&lt;br /&gt;
      ...&lt;br /&gt;
      /com_mycomponent&lt;br /&gt;
        /view1&lt;br /&gt;
          default.php&lt;br /&gt;
        /view2&lt;br /&gt;
          default.php&lt;br /&gt;
      ...&lt;br /&gt;
      /layouts&lt;br /&gt;
        /joomla&lt;br /&gt;
          /content&lt;br /&gt;
            /info_block&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        default.php          &lt;br /&gt;
        alternative.php&lt;br /&gt;
      ...&lt;br /&gt;
    /images&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule-logo.png&lt;br /&gt;
      ...&lt;br /&gt;
    /js&lt;br /&gt;
      /mod_yourmodule&lt;br /&gt;
        yourmodule.js&lt;br /&gt;
    ...&lt;br /&gt;
  ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The illustration above shows the paths and some of the files in your templates folder.&lt;br /&gt;
If we add files in those directories, they will be used instead of the extensions original files.&lt;br /&gt;
You can use the Template Manager to easily create overrides in the html path.  [[J3.x:How_to_use_the_Template_Manager|J3.x:How to use the Template Manager]]&lt;br /&gt;
&lt;br /&gt;
Be aware of that if you use a template including overrides, you have to find a way to protect your custom overrides when the template is updated. e.g. if you use the Beez3 template, you can create a copy of this template. See the Template Manager.&lt;br /&gt;
&lt;br /&gt;
We can also override css, images and javascripts that are loaded with the JHtml functions and &#039;relative&#039; to the media/ folder. We&#039;ll show this with the custom module you have created in this tutorial.&lt;br /&gt;
&lt;br /&gt;
=== Overriding ===&lt;br /&gt;
&lt;br /&gt;
Use the Template Manager or your file manager to copy the default.php from the /tmpl folder in your module to yourtemplate/html/mod_yourmodule/ as shown above. Open the copy with your editor and make some visual changes. Maybe you want to replace the Bootstrap classes if your temlate is not loading the Bootstrap Css. If you now refresh the browser page you&#039;ll see the changes.&lt;br /&gt;
&lt;br /&gt;
You can do the same with components. As shown above, you have to add one folder per component view, where you add the output file. The name is not always default.php.  &lt;br /&gt;
&lt;br /&gt;
Copy the yourmodule.css file from media/mod_yourmodule/css to yourtemplate/css/mod_yourmodule/. Open this file and change css classes e.g. text to another color. Reload the page in the browser. Be aware of the browser cache. It can be, that you have to clear it to get the changed css loaded.&lt;br /&gt;
&lt;br /&gt;
Copy an image to yourtemplate/images/mod_yourmodule/ and rename it to the same name as used in the default.php. Reload the page and you&#039;ll see your image.&lt;br /&gt;
&lt;br /&gt;
The same possibility is valid for javascript. If they are loaded &#039;relative&#039; to the media/ path you can copy them to yourtemplate/js/mod_yourmodule/ and change them.&lt;br /&gt;
&lt;br /&gt;
As you remember we added two options to the module settings, load_css and load_js. A administrator/user may want to load css and/or javascript in other ways. If you use those parameters, the administrator can turn off the loading of your modules css and/or javacript without overriding the default.php. This is more important for components as css and javascript normaly not is loaded in overridable code.&lt;br /&gt;
&lt;br /&gt;
Example - optional exclusion of the css:&lt;br /&gt;
==== default.php Css parameter ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
if ($params-&amp;gt;get(&#039;load_css&#039;, 1)) {&lt;br /&gt;
   JHtml::stylesheet(&#039;mod_yourmodule/yourmodule.css&#039;, false, true, false);&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The html/layouts path ===&lt;br /&gt;
&lt;br /&gt;
A new possibility to Joomla! output is the reuse of parts of a view ( JLayout ).  An example is the use of the same &#039;layout&#039; in many of the different article views.  JLayout files use the layout paths. In the Joomla! root you can find a /layouts folder that include the core JLayout files. Have a look at the available ones. Third party components usually use an own folder in their backend path.&lt;br /&gt;
&lt;br /&gt;
To override those reused &#039;layouts&#039; you copy them to the corresponding path in your templates directory and make the changes. They will be automaticly loaded instead of the original one.&lt;br /&gt;
&lt;br /&gt;
It&#039;s not likely that you can reuse a JLayout file in a module, but it is possible.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125223</id>
		<title>User:Over/Step by step to a Joomla Module - Installation package</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125223"/>
		<updated>2014-09-05T11:54:41Z</updated>

		<summary type="html">&lt;p&gt;Over: /* 2. Traditional way */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to become an installable extension for any Joomla! 3.x site. e.g. after testing the functionality on your local installation you can upload and install it on your live site with a few clicks.&lt;br /&gt;
&lt;br /&gt;
=== Language files ===&lt;br /&gt;
&lt;br /&gt;
The language files hold the textstrings that are used for descriptions, field labels, field descriptions and any other static texts. You can also translate the textstrings for any language code. The default language code is en-GB, Great Britain english. In version 3 the english &amp;quot;translation&amp;quot; is in most cases loaded before any other specific language. i.e. you should always keep those files up to date.&lt;br /&gt;
&lt;br /&gt;
As in the first part of the tutorial we&#039;ll use skeleton files. In the folder, where you unzipped the downloaded file, you can find two language files, en-GB.mod_yourmodule.ini and en-GB.mod_yourmodule.sys.ini Copy those to the Joomla! en-GB language folder. path/to/joomla/language/en-GB. You can also find a language folder in the administrator/ path used for backend extensions and all plug ins.&lt;br /&gt;
&lt;br /&gt;
As always, change files named ...yourmodule... to the name you did choose. Open the first file en-GB.mod_yourmodule.ini&lt;br /&gt;
&lt;br /&gt;
===== en-GB.mod_yourmodule.ini =====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Copyright (C) 2014 Joomla Doe&lt;br /&gt;
; Translater Joomla Doe&lt;br /&gt;
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php&lt;br /&gt;
; Note : All ini files need to be saved as UTF-8 - No BOM&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE=&amp;quot;Your own module&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of my module. This one in .ini is shown when editing the module in the Module Manager. Yoü can e.g. add some tips to the confuguration and a link to a help page on your site&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the top we find some comments. As you see, you have to use ; in front of the comments. If you have friendly helpers that translate your extension, it&#039;s nice to have a line with the translators name. The use of character set UTF-8 is noted. For the language string constants you should follow the Joomla! best practice i.e. start all language constants with the extension name. &#039;&#039;&#039;The language constants have to be in upper case with _ (underscore) as divider ending with a =. The text has to be within &amp;quot; double quote.&#039;&#039;&#039; Do not use double quote within the text or you will have to find out how to use __QQ__. &#039;&#039;&#039;No line break is allowed!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
; An example with double quote&lt;br /&gt;
MOD_YOURMODULE_MY_QUOTE=&amp;quot;My value is &amp;quot;_QQ_&amp;quot;great!&amp;quot;_QQ_&amp;quot;. I like it&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is no good reference available at the time of writing. Please change this link if a better is found. [[Specification_of_language_files|Specification of language files]]&lt;br /&gt;
&lt;br /&gt;
Change the two MOD_YOURMODULE, change the first text to a &amp;quot;human&amp;quot; name of your module and change the description. Again: in one line! &#039;&#039;&#039;no line break is allowed!&#039;&#039;&#039;. If you add e.g. a link remeber &amp;quot;_QQ_&amp;quot; for double quotes. Save this file and copy the text except the description content. The second file has almost the same content at this stage. Open en-GB.mod_yourmodule.sys.ini and paste the copied text replacing the text i.e. not the description text.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of your module. This one in .sys.ini is shown when choosing a new module in the module manager and in the extension manager. Keep this shorter.&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the description and save.&lt;br /&gt;
&lt;br /&gt;
The difference between those is that the .sys.ini file is loaded in cases like module lists where no module fields are shown. We´ll see another use of the .sys.ini below.&lt;br /&gt;
&lt;br /&gt;
As promised in the first part of the tutorial, you can now see the reason for using mod_yourmodule as module name in the xml file. Go to Module Manager, click on new. You will find your module with the name from the language file. Next we will fix the description. Before you close the files copy the constant MOD_YOURMODULE_XML_DESCRIPTION-&lt;br /&gt;
&lt;br /&gt;
Open mod_yourmodule.xml from the server and find the description line. Replace the description with your copied language constant MOD_YOURMODULE_XML_DESCRIPTION.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Description ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;MOD_YOURMODULE_XML_DESCRIPTION&amp;lt;/description&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can make the same test as before in the Module Manager and you&#039;ll see that the description comes from the language files.&lt;br /&gt;
&lt;br /&gt;
=== Parameters - Options ===&lt;br /&gt;
If you choose your enabled module for edit in the Module Manager you&#039;ll se some default options under the advanced tab. Let&#039;s add some more options in the xml file and add the used language strings before we create the first installable package.&lt;br /&gt;
&lt;br /&gt;
Add the following where you find the config part. We will see more around form fields in a later tutorial part.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Config ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;config&amp;gt;&lt;br /&gt;
      &amp;lt;fields name=&amp;quot;params&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;options&amp;quot; label=&amp;quot;COM_MODULES_BASIC_FIELDSET_LABEL&amp;quot;&lt;br /&gt;
            addfieldpath=&amp;quot;/administrator/components/com_content/models/fields/modal&amp;quot;&lt;br /&gt;
	 &amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;article_id&amp;quot;&lt;br /&gt;
               type=&amp;quot;modal_article&amp;quot;&lt;br /&gt;
               default=&amp;quot;&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_DESC&amp;quot; &amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;advanced&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_css&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_js&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;layout&amp;quot;&lt;br /&gt;
               type=&amp;quot;modulelayout&amp;quot;&lt;br /&gt;
               label=&amp;quot;JFIELD_ALT_LAYOUT_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;JFIELD_ALT_MODULE_LAYOUT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;moduleclass_sfx&amp;quot;&lt;br /&gt;
               type=&amp;quot;textarea&amp;quot; rows=&amp;quot;3&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache&amp;quot;&lt;br /&gt;
               type=&amp;quot;list&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHING_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHING_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JGLOBAL_USE_GLOBAL&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;COM_MODULES_FIELD_VALUE_NOCACHING&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache_time&amp;quot;&lt;br /&gt;
               type=&amp;quot;text&amp;quot;&lt;br /&gt;
               default=&amp;quot;900&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cachemode&amp;quot;&lt;br /&gt;
               type=&amp;quot;hidden&amp;quot;&lt;br /&gt;
               default=&amp;quot;static&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;static&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
      &amp;lt;/fields&amp;gt;&lt;br /&gt;
   &amp;lt;/config&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the fieldset options we add an option field &amp;quot;article_id&amp;quot; that we will use later. This field calls a modal window where you can choose an article. Fieldset options is shown in the tab Options in the Module Manager. If you use a fieldset named basic you&#039;ll have those fields in the first tab. We also add some standard option fields to the &amp;quot;Advanced&amp;quot; tab. We do not have to add the text constants used in the Advanced part since they are standard. Remains the two strings used for the article field. Well, we added two fields in the advanced tab, load_css and load_js with language strings that need to be added. We&#039;ll come back to the use of those options later. &lt;br /&gt;
&lt;br /&gt;
Follow this link to read more about [http://docs.joomla.org/Module Joomla modules and the Modules Manager]&lt;br /&gt;
&lt;br /&gt;
=== Add strings to language file ===&lt;br /&gt;
Save the xml file and open the language file. The one without .sys.&lt;br /&gt;
&lt;br /&gt;
Add the 6 strings and save.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.ini - New strings ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_DESC=&amp;quot;Choose an article to be shown by the module.&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_LABEL=&amp;quot;Article&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_DESC=&amp;quot;You can disable the modules css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL=&amp;quot;Load Css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_DESC=&amp;quot;You can disable the modules JavaScript&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_LABEL=&amp;quot;Load JavaScript&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Final change to the xml file ===&lt;br /&gt;
&lt;br /&gt;
Before we create the first installation file we will add the language tags to the xml file below the &amp;lt;/files&amp;gt; tag.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Final ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
   &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We use a folder named langs here, because we will use the folder language for a trick. If you include other language files just add lines with the correspondent language identifier.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;large-12 panel radius&amp;quot; style=&amp;quot;background-color:#fff; border:1px solid #aaa; margin:1em 0;&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;For those of you that have some knowledge of Joomla development:&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
Do not add the /language folder to the xml file. It is autoloaded. i.e. extracted and used in the installation process by default.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the xml file.&lt;br /&gt;
&lt;br /&gt;
=== Create the compressed installation file ===&lt;br /&gt;
Now we have everything to create the first version of the installation file.&lt;br /&gt;
&lt;br /&gt;
Inside the folder you created on yor local system at the start of the tutorial &#039;somewhere&#039;/j_module_tutorial/new_module you add three sub directories. langs, language and tmpl. Now you copy the files in the other direction. From the web directory to the new one. It should look something like this ( remember - yourmodule - is a placeholder for your choosen module name ):&lt;br /&gt;
&lt;br /&gt;
* .../new_module&lt;br /&gt;
** .../new_module/langs&lt;br /&gt;
*** en-GB.mod_yourmodule.ini&lt;br /&gt;
*** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
*** anyother-language.mod_yourmodule.in&lt;br /&gt;
*** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
** .../new_module/language&lt;br /&gt;
*** .../new_module/language/en-GB&lt;br /&gt;
**** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
*** .../new_module/language/anyother-language&lt;br /&gt;
**** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
** .../new_module/tmpl&lt;br /&gt;
*** default.php&lt;br /&gt;
** mod_yourmodule.php&lt;br /&gt;
** mod_yourmodule.xml&lt;br /&gt;
&lt;br /&gt;
As a last step we&#039;ll edit the .../new_module/language/en-GB/mod_yourmodule.sys.ini to show a different message at installation/upgrade.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.sys.ini - Installation message ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;Thank you for installing / update the Your own module. This module displays an article text in a module position. To activate you go to the module manager and edit this module or create a new entry. Select the article you want to show. Please visit www.mysite.com for more information. If you like it please add a review on JED.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you edit the description text to include a &amp;quot;Thanks&amp;quot; and other informations only relevant directly after the installation / upgrade this is a trick to achieve this. Only .../new_module/langs/mod_yourmodule.sys.ini will be copied and used after the installation.&lt;br /&gt;
&lt;br /&gt;
You can find two short descriptions of alternative handling of the language files at the end of this page.&lt;br /&gt;
&lt;br /&gt;
Now we compress the files. The Zip type is recommended as it has native support by most systems. In Windows you go to the .../new_module folder. Mark the included folders and files, right click and choose {{rarr|Send to,ZIP compressed folder}}.&lt;br /&gt;
&lt;br /&gt;
Rename the .zip file to mod_yourmodule_1_0_0.zip i.e. including the version number. You should better move this file to another folder. It is easy forgotten NOT to include it, the next time you create a zipped file.&lt;br /&gt;
&lt;br /&gt;
You made a backup before starting the tutorial? Well, only in case of ...&lt;br /&gt;
&lt;br /&gt;
First you uninstall the module to get a complete new installation {{rarr|Extensions,Manager,Manage}} Look up the module. Filter e.g. Location = Site, Type=Module and/or name.&lt;br /&gt;
&lt;br /&gt;
When the module is uninstalled you go to Install, browse to your installation zip file and click the Upload &amp;amp;amp; Install button. You&#039;ll see the description you edited as installation message. Go to the Module Manager. This time you should find an entry in the Module list. Choose this and enable it, as you did after the Discover in the first part of the tutorial. You can also see that the description is the one from your .ini file. To check the description from .sys.ini click on NEW module. This is not the one you saw directly after the installation.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this part of the module tutorial. The next part will show you how to retrieve data and add some Css styling to your module.&lt;br /&gt;
&lt;br /&gt;
=== Alternative language files  handling ===&lt;br /&gt;
&lt;br /&gt;
For both alternatives you have to add all language files to subfolders in the /language folder. Be aware that the folder name is mandatory! &lt;br /&gt;
&lt;br /&gt;
You can use the language files from the /langs folder in the example above. Do not add a long description to the .sys.ini files, as it will be used for the module lists. Of course you have to remove the /langs folder, if you want to test by changing the example above.&lt;br /&gt;
&lt;br /&gt;
Resulting folder:&lt;br /&gt;
&lt;br /&gt;
* /language&lt;br /&gt;
**/language/en-GB&lt;br /&gt;
*** en-GB.mod_yourmodule.ini&lt;br /&gt;
*** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
** /language/anyother-language&lt;br /&gt;
*** anyother-language.mod_yourmodule.ini&lt;br /&gt;
*** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
&lt;br /&gt;
==== 1. Easiest way  ====&lt;br /&gt;
&lt;br /&gt;
Add a folder tag to the files area in the xml file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;folder&amp;gt;language&amp;lt;/folder&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The folder will be stored in the extensions folder and no files in the core language folder.&lt;br /&gt;
&lt;br /&gt;
==== 2. Traditional way  ====&lt;br /&gt;
&lt;br /&gt;
Add all single language files to the languages tag in the xml file. Be aware of the extra folder name required (= language tag).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;language&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt; &lt;br /&gt;
  &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files are saved to the core language folder in the traditional way.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125222</id>
		<title>User:Over/Step by step to a Joomla Module - Installation package</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125222"/>
		<updated>2014-09-05T11:11:22Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Alternative language files  handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to become an installable extension for any Joomla! 3.x site. e.g. after testing the functionality on your local installation you can upload and install it on your live site with a few clicks.&lt;br /&gt;
&lt;br /&gt;
=== Language files ===&lt;br /&gt;
&lt;br /&gt;
The language files hold the textstrings that are used for descriptions, field labels, field descriptions and any other static texts. You can also translate the textstrings for any language code. The default language code is en-GB, Great Britain english. In version 3 the english &amp;quot;translation&amp;quot; is in most cases loaded before any other specific language. i.e. you should always keep those files up to date.&lt;br /&gt;
&lt;br /&gt;
As in the first part of the tutorial we&#039;ll use skeleton files. In the folder, where you unzipped the downloaded file, you can find two language files, en-GB.mod_yourmodule.ini and en-GB.mod_yourmodule.sys.ini Copy those to the Joomla! en-GB language folder. path/to/joomla/language/en-GB. You can also find a language folder in the administrator/ path used for backend extensions and all plug ins.&lt;br /&gt;
&lt;br /&gt;
As always, change files named ...yourmodule... to the name you did choose. Open the first file en-GB.mod_yourmodule.ini&lt;br /&gt;
&lt;br /&gt;
===== en-GB.mod_yourmodule.ini =====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Copyright (C) 2014 Joomla Doe&lt;br /&gt;
; Translater Joomla Doe&lt;br /&gt;
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php&lt;br /&gt;
; Note : All ini files need to be saved as UTF-8 - No BOM&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE=&amp;quot;Your own module&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of my module. This one in .ini is shown when editing the module in the Module Manager. Yoü can e.g. add some tips to the confuguration and a link to a help page on your site&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the top we find some comments. As you see, you have to use ; in front of the comments. If you have friendly helpers that translate your extension, it&#039;s nice to have a line with the translators name. The use of character set UTF-8 is noted. For the language string constants you should follow the Joomla! best practice i.e. start all language constants with the extension name. &#039;&#039;&#039;The language constants have to be in upper case with _ (underscore) as divider ending with a =. The text has to be within &amp;quot; double quote.&#039;&#039;&#039; Do not use double quote within the text or you will have to find out how to use __QQ__. &#039;&#039;&#039;No line break is allowed!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
; An example with double quote&lt;br /&gt;
MOD_YOURMODULE_MY_QUOTE=&amp;quot;My value is &amp;quot;_QQ_&amp;quot;great!&amp;quot;_QQ_&amp;quot;. I like it&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is no good reference available at the time of writing. Please change this link if a better is found. [[Specification_of_language_files|Specification of language files]]&lt;br /&gt;
&lt;br /&gt;
Change the two MOD_YOURMODULE, change the first text to a &amp;quot;human&amp;quot; name of your module and change the description. Again: in one line! &#039;&#039;&#039;no line break is allowed!&#039;&#039;&#039;. If you add e.g. a link remeber &amp;quot;_QQ_&amp;quot; for double quotes. Save this file and copy the text except the description content. The second file has almost the same content at this stage. Open en-GB.mod_yourmodule.sys.ini and paste the copied text replacing the text i.e. not the description text.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of your module. This one in .sys.ini is shown when choosing a new module in the module manager and in the extension manager. Keep this shorter.&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the description and save.&lt;br /&gt;
&lt;br /&gt;
The difference between those is that the .sys.ini file is loaded in cases like module lists where no module fields are shown. We´ll see another use of the .sys.ini below.&lt;br /&gt;
&lt;br /&gt;
As promised in the first part of the tutorial, you can now see the reason for using mod_yourmodule as module name in the xml file. Go to Module Manager, click on new. You will find your module with the name from the language file. Next we will fix the description. Before you close the files copy the constant MOD_YOURMODULE_XML_DESCRIPTION-&lt;br /&gt;
&lt;br /&gt;
Open mod_yourmodule.xml from the server and find the description line. Replace the description with your copied language constant MOD_YOURMODULE_XML_DESCRIPTION.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Description ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;MOD_YOURMODULE_XML_DESCRIPTION&amp;lt;/description&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can make the same test as before in the Module Manager and you&#039;ll see that the description comes from the language files.&lt;br /&gt;
&lt;br /&gt;
=== Parameters - Options ===&lt;br /&gt;
If you choose your enabled module for edit in the Module Manager you&#039;ll se some default options under the advanced tab. Let&#039;s add some more options in the xml file and add the used language strings before we create the first installable package.&lt;br /&gt;
&lt;br /&gt;
Add the following where you find the config part. We will see more around form fields in a later tutorial part.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Config ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;config&amp;gt;&lt;br /&gt;
      &amp;lt;fields name=&amp;quot;params&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;options&amp;quot; label=&amp;quot;COM_MODULES_BASIC_FIELDSET_LABEL&amp;quot;&lt;br /&gt;
            addfieldpath=&amp;quot;/administrator/components/com_content/models/fields/modal&amp;quot;&lt;br /&gt;
	 &amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;article_id&amp;quot;&lt;br /&gt;
               type=&amp;quot;modal_article&amp;quot;&lt;br /&gt;
               default=&amp;quot;&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_DESC&amp;quot; &amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;advanced&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_css&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_js&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;layout&amp;quot;&lt;br /&gt;
               type=&amp;quot;modulelayout&amp;quot;&lt;br /&gt;
               label=&amp;quot;JFIELD_ALT_LAYOUT_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;JFIELD_ALT_MODULE_LAYOUT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;moduleclass_sfx&amp;quot;&lt;br /&gt;
               type=&amp;quot;textarea&amp;quot; rows=&amp;quot;3&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache&amp;quot;&lt;br /&gt;
               type=&amp;quot;list&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHING_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHING_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JGLOBAL_USE_GLOBAL&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;COM_MODULES_FIELD_VALUE_NOCACHING&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache_time&amp;quot;&lt;br /&gt;
               type=&amp;quot;text&amp;quot;&lt;br /&gt;
               default=&amp;quot;900&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cachemode&amp;quot;&lt;br /&gt;
               type=&amp;quot;hidden&amp;quot;&lt;br /&gt;
               default=&amp;quot;static&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;static&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
      &amp;lt;/fields&amp;gt;&lt;br /&gt;
   &amp;lt;/config&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the fieldset options we add an option field &amp;quot;article_id&amp;quot; that we will use later. This field calls a modal window where you can choose an article. Fieldset options is shown in the tab Options in the Module Manager. If you use a fieldset named basic you&#039;ll have those fields in the first tab. We also add some standard option fields to the &amp;quot;Advanced&amp;quot; tab. We do not have to add the text constants used in the Advanced part since they are standard. Remains the two strings used for the article field. Well, we added two fields in the advanced tab, load_css and load_js with language strings that need to be added. We&#039;ll come back to the use of those options later. &lt;br /&gt;
&lt;br /&gt;
Follow this link to read more about [http://docs.joomla.org/Module Joomla modules and the Modules Manager]&lt;br /&gt;
&lt;br /&gt;
=== Add strings to language file ===&lt;br /&gt;
Save the xml file and open the language file. The one without .sys.&lt;br /&gt;
&lt;br /&gt;
Add the 6 strings and save.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.ini - New strings ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_DESC=&amp;quot;Choose an article to be shown by the module.&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_LABEL=&amp;quot;Article&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_DESC=&amp;quot;You can disable the modules css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL=&amp;quot;Load Css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_DESC=&amp;quot;You can disable the modules JavaScript&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_LABEL=&amp;quot;Load JavaScript&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Final change to the xml file ===&lt;br /&gt;
&lt;br /&gt;
Before we create the first installation file we will add the language tags to the xml file below the &amp;lt;/files&amp;gt; tag.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Final ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
   &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We use a folder named langs here, because we will use the folder language for a trick. If you include other language files just add lines with the correspondent language identifier.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;large-12 panel radius&amp;quot; style=&amp;quot;background-color:#fff; border:1px solid #aaa; margin:1em 0;&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;For those of you that have some knowledge of Joomla development:&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
Do not add the /language folder to the xml file. It is autoloaded. i.e. extracted and used in the installation process by default.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the xml file.&lt;br /&gt;
&lt;br /&gt;
=== Create the compressed installation file ===&lt;br /&gt;
Now we have everything to create the first version of the installation file.&lt;br /&gt;
&lt;br /&gt;
Inside the folder you created on yor local system at the start of the tutorial &#039;somewhere&#039;/j_module_tutorial/new_module you add three sub directories. langs, language and tmpl. Now you copy the files in the other direction. From the web directory to the new one. It should look something like this ( remember - yourmodule - is a placeholder for your choosen module name ):&lt;br /&gt;
&lt;br /&gt;
* .../new_module&lt;br /&gt;
** .../new_module/langs&lt;br /&gt;
*** en-GB.mod_yourmodule.ini&lt;br /&gt;
*** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
*** anyother-language.mod_yourmodule.in&lt;br /&gt;
*** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
** .../new_module/language&lt;br /&gt;
*** .../new_module/language/en-GB&lt;br /&gt;
**** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
*** .../new_module/language/anyother-language&lt;br /&gt;
**** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
** .../new_module/tmpl&lt;br /&gt;
*** default.php&lt;br /&gt;
** mod_yourmodule.php&lt;br /&gt;
** mod_yourmodule.xml&lt;br /&gt;
&lt;br /&gt;
As a last step we&#039;ll edit the .../new_module/language/en-GB/mod_yourmodule.sys.ini to show a different message at installation/upgrade.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.sys.ini - Installation message ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;Thank you for installing / update the Your own module. This module displays an article text in a module position. To activate you go to the module manager and edit this module or create a new entry. Select the article you want to show. Please visit www.mysite.com for more information. If you like it please add a review on JED.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you edit the description text to include a &amp;quot;Thanks&amp;quot; and other informations only relevant directly after the installation / upgrade this is a trick to achieve this. Only .../new_module/langs/mod_yourmodule.sys.ini will be copied and used after the installation.&lt;br /&gt;
&lt;br /&gt;
You can find two short descriptions of alternative handling of the language files at the end of this page.&lt;br /&gt;
&lt;br /&gt;
Now we compress the files. The Zip type is recommended as it has native support by most systems. In Windows you go to the .../new_module folder. Mark the included folders and files, right click and choose {{rarr|Send to,ZIP compressed folder}}.&lt;br /&gt;
&lt;br /&gt;
Rename the .zip file to mod_yourmodule_1_0_0.zip i.e. including the version number. You should better move this file to another folder. It is easy forgotten NOT to include it, the next time you create a zipped file.&lt;br /&gt;
&lt;br /&gt;
You made a backup before starting the tutorial? Well, only in case of ...&lt;br /&gt;
&lt;br /&gt;
First you uninstall the module to get a complete new installation {{rarr|Extensions,Manager,Manage}} Look up the module. Filter e.g. Location = Site, Type=Module and/or name.&lt;br /&gt;
&lt;br /&gt;
When the module is uninstalled you go to Install, browse to your installation zip file and click the Upload &amp;amp;amp; Install button. You&#039;ll see the description you edited as installation message. Go to the Module Manager. This time you should find an entry in the Module list. Choose this and enable it, as you did after the Discover in the first part of the tutorial. You can also see that the description is the one from your .ini file. To check the description from .sys.ini click on NEW module. This is not the one you saw directly after the installation.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this part of the module tutorial. The next part will show you how to retrieve data and add some Css styling to your module.&lt;br /&gt;
&lt;br /&gt;
=== Alternative language files  handling ===&lt;br /&gt;
&lt;br /&gt;
For both alternatives you have to add all language files to subfolders in the /language folder. Be aware that the folder name is mandatory! &lt;br /&gt;
&lt;br /&gt;
You can use the language files from the /langs folder in the example above. Do not add a long description to the .sys.ini files, as it will be used for the module lists. Of course you have to remove the /langs folder, if you want to test by changing the example above.&lt;br /&gt;
&lt;br /&gt;
Resulting folder:&lt;br /&gt;
&lt;br /&gt;
* /language&lt;br /&gt;
**/language/en-GB&lt;br /&gt;
*** en-GB.mod_yourmodule.ini&lt;br /&gt;
*** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
** /language/anyother-language&lt;br /&gt;
*** anyother-language.mod_yourmodule.ini&lt;br /&gt;
*** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
&lt;br /&gt;
==== 1. Easiest way  ====&lt;br /&gt;
&lt;br /&gt;
Add a folder tag to the files area in the xml file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;folder&amp;gt;language&amp;lt;/folder&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The folder will be stored in the extensions folder and no files in the core language folder.&lt;br /&gt;
&lt;br /&gt;
==== 2. Traditional way  ====&lt;br /&gt;
&lt;br /&gt;
Add all single language files to the languages tag in the xml file. Be aware of the extra folder name required (= language tag).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;language&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt; &lt;br /&gt;
  &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files are saved the core language folder in the traditional way.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125221</id>
		<title>User:Over/Step by step to a Joomla Module - Installation package</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User:Over/Step_by_step_to_a_Joomla_Module_-_Installation_package&amp;diff=125221"/>
		<updated>2014-09-05T11:02:49Z</updated>

		<summary type="html">&lt;p&gt;Over: /* Create the compressed installation file */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{User:Over/Step_by_step_to_a_Joomla_Module/nav}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
In this step we will extend &amp;quot;Your module&amp;quot; to become an installable extension for any Joomla! 3.x site. e.g. after testing the functionality on your local installation you can upload and install it on your live site with a few clicks.&lt;br /&gt;
&lt;br /&gt;
=== Language files ===&lt;br /&gt;
&lt;br /&gt;
The language files hold the textstrings that are used for descriptions, field labels, field descriptions and any other static texts. You can also translate the textstrings for any language code. The default language code is en-GB, Great Britain english. In version 3 the english &amp;quot;translation&amp;quot; is in most cases loaded before any other specific language. i.e. you should always keep those files up to date.&lt;br /&gt;
&lt;br /&gt;
As in the first part of the tutorial we&#039;ll use skeleton files. In the folder, where you unzipped the downloaded file, you can find two language files, en-GB.mod_yourmodule.ini and en-GB.mod_yourmodule.sys.ini Copy those to the Joomla! en-GB language folder. path/to/joomla/language/en-GB. You can also find a language folder in the administrator/ path used for backend extensions and all plug ins.&lt;br /&gt;
&lt;br /&gt;
As always, change files named ...yourmodule... to the name you did choose. Open the first file en-GB.mod_yourmodule.ini&lt;br /&gt;
&lt;br /&gt;
===== en-GB.mod_yourmodule.ini =====&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; Copyright (C) 2014 Joomla Doe&lt;br /&gt;
; Translater Joomla Doe&lt;br /&gt;
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php&lt;br /&gt;
; Note : All ini files need to be saved as UTF-8 - No BOM&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE=&amp;quot;Your own module&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of my module. This one in .ini is shown when editing the module in the Module Manager. Yoü can e.g. add some tips to the confuguration and a link to a help page on your site&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the top we find some comments. As you see, you have to use ; in front of the comments. If you have friendly helpers that translate your extension, it&#039;s nice to have a line with the translators name. The use of character set UTF-8 is noted. For the language string constants you should follow the Joomla! best practice i.e. start all language constants with the extension name. &#039;&#039;&#039;The language constants have to be in upper case with _ (underscore) as divider ending with a =. The text has to be within &amp;quot; double quote.&#039;&#039;&#039; Do not use double quote within the text or you will have to find out how to use __QQ__. &#039;&#039;&#039;No line break is allowed!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
; An example with double quote&lt;br /&gt;
MOD_YOURMODULE_MY_QUOTE=&amp;quot;My value is &amp;quot;_QQ_&amp;quot;great!&amp;quot;_QQ_&amp;quot;. I like it&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is no good reference available at the time of writing. Please change this link if a better is found. [[Specification_of_language_files|Specification of language files]]&lt;br /&gt;
&lt;br /&gt;
Change the two MOD_YOURMODULE, change the first text to a &amp;quot;human&amp;quot; name of your module and change the description. Again: in one line! &#039;&#039;&#039;no line break is allowed!&#039;&#039;&#039;. If you add e.g. a link remeber &amp;quot;_QQ_&amp;quot; for double quotes. Save this file and copy the text except the description content. The second file has almost the same content at this stage. Open en-GB.mod_yourmodule.sys.ini and paste the copied text replacing the text i.e. not the description text.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;This is the description of your module. This one in .sys.ini is shown when choosing a new module in the module manager and in the extension manager. Keep this shorter.&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the description and save.&lt;br /&gt;
&lt;br /&gt;
The difference between those is that the .sys.ini file is loaded in cases like module lists where no module fields are shown. We´ll see another use of the .sys.ini below.&lt;br /&gt;
&lt;br /&gt;
As promised in the first part of the tutorial, you can now see the reason for using mod_yourmodule as module name in the xml file. Go to Module Manager, click on new. You will find your module with the name from the language file. Next we will fix the description. Before you close the files copy the constant MOD_YOURMODULE_XML_DESCRIPTION-&lt;br /&gt;
&lt;br /&gt;
Open mod_yourmodule.xml from the server and find the description line. Replace the description with your copied language constant MOD_YOURMODULE_XML_DESCRIPTION.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Description ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;MOD_YOURMODULE_XML_DESCRIPTION&amp;lt;/description&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can make the same test as before in the Module Manager and you&#039;ll see that the description comes from the language files.&lt;br /&gt;
&lt;br /&gt;
=== Parameters - Options ===&lt;br /&gt;
If you choose your enabled module for edit in the Module Manager you&#039;ll se some default options under the advanced tab. Let&#039;s add some more options in the xml file and add the used language strings before we create the first installable package.&lt;br /&gt;
&lt;br /&gt;
Add the following where you find the config part. We will see more around form fields in a later tutorial part.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Config ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;config&amp;gt;&lt;br /&gt;
      &amp;lt;fields name=&amp;quot;params&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;options&amp;quot; label=&amp;quot;COM_MODULES_BASIC_FIELDSET_LABEL&amp;quot;&lt;br /&gt;
            addfieldpath=&amp;quot;/administrator/components/com_content/models/fields/modal&amp;quot;&lt;br /&gt;
	 &amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;article_id&amp;quot;&lt;br /&gt;
               type=&amp;quot;modal_article&amp;quot;&lt;br /&gt;
               default=&amp;quot;&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_ARTICLE_DESC&amp;quot; &amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
         &amp;lt;fieldset name=&amp;quot;advanced&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_css&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_CSS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
                  &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;load_js&amp;quot;&lt;br /&gt;
               type=&amp;quot;radio&amp;quot;&lt;br /&gt;
               class=&amp;quot;btn-group&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;MOD_YOURMODULE_FIELD_LOAD_JS_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;layout&amp;quot;&lt;br /&gt;
               type=&amp;quot;modulelayout&amp;quot;&lt;br /&gt;
               label=&amp;quot;JFIELD_ALT_LAYOUT_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;JFIELD_ALT_MODULE_LAYOUT_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;moduleclass_sfx&amp;quot;&lt;br /&gt;
               type=&amp;quot;textarea&amp;quot; rows=&amp;quot;3&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_MODULECLASS_SFX_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache&amp;quot;&lt;br /&gt;
               type=&amp;quot;list&amp;quot;&lt;br /&gt;
               default=&amp;quot;1&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHING_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHING_DESC&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JGLOBAL_USE_GLOBAL&amp;lt;/option&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;COM_MODULES_FIELD_VALUE_NOCACHING&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cache_time&amp;quot;&lt;br /&gt;
               type=&amp;quot;text&amp;quot;&lt;br /&gt;
               default=&amp;quot;900&amp;quot;&lt;br /&gt;
               label=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_LABEL&amp;quot;&lt;br /&gt;
               description=&amp;quot;COM_MODULES_FIELD_CACHE_TIME_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
            &amp;lt;field&lt;br /&gt;
               name=&amp;quot;cachemode&amp;quot;&lt;br /&gt;
               type=&amp;quot;hidden&amp;quot;&lt;br /&gt;
               default=&amp;quot;static&amp;quot;&amp;gt;&lt;br /&gt;
               &amp;lt;option value=&amp;quot;static&amp;quot;&amp;gt;&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;/field&amp;gt;&lt;br /&gt;
         &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
      &amp;lt;/fields&amp;gt;&lt;br /&gt;
   &amp;lt;/config&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the fieldset options we add an option field &amp;quot;article_id&amp;quot; that we will use later. This field calls a modal window where you can choose an article. Fieldset options is shown in the tab Options in the Module Manager. If you use a fieldset named basic you&#039;ll have those fields in the first tab. We also add some standard option fields to the &amp;quot;Advanced&amp;quot; tab. We do not have to add the text constants used in the Advanced part since they are standard. Remains the two strings used for the article field. Well, we added two fields in the advanced tab, load_css and load_js with language strings that need to be added. We&#039;ll come back to the use of those options later. &lt;br /&gt;
&lt;br /&gt;
Follow this link to read more about [http://docs.joomla.org/Module Joomla modules and the Modules Manager]&lt;br /&gt;
&lt;br /&gt;
=== Add strings to language file ===&lt;br /&gt;
Save the xml file and open the language file. The one without .sys.&lt;br /&gt;
&lt;br /&gt;
Add the 6 strings and save.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.ini - New strings ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_DESC=&amp;quot;Choose an article to be shown by the module.&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_ARTICLE_LABEL=&amp;quot;Article&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_DESC=&amp;quot;You can disable the modules css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_CSS_LABEL=&amp;quot;Load Css&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_DESC=&amp;quot;You can disable the modules JavaScript&amp;quot;&lt;br /&gt;
MOD_YOURMODULE_FIELD_LOAD_JS_LABEL=&amp;quot;Load JavaScript&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Final change to the xml file ===&lt;br /&gt;
&lt;br /&gt;
Before we create the first installation file we will add the language tags to the xml file below the &amp;lt;/files&amp;gt; tag.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.xml - Final ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;langs&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
   &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We use a folder named langs here, because we will use the folder language for a trick. If you include other language files just add lines with the correspondent language identifier.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;large-12 panel radius&amp;quot; style=&amp;quot;background-color:#fff; border:1px solid #aaa; margin:1em 0;&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;For those of you that have some knowledge of Joomla development:&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
Do not add the /language folder to the xml file. It is autoloaded. i.e. extracted and used in the installation process by default.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the xml file.&lt;br /&gt;
&lt;br /&gt;
=== Create the compressed installation file ===&lt;br /&gt;
Now we have everything to create the first version of the installation file.&lt;br /&gt;
&lt;br /&gt;
Inside the folder you created on yor local system at the start of the tutorial &#039;somewhere&#039;/j_module_tutorial/new_module you add three sub directories. langs, language and tmpl. Now you copy the files in the other direction. From the web directory to the new one. It should look something like this ( remember - yourmodule - is a placeholder for your choosen module name ):&lt;br /&gt;
&lt;br /&gt;
* .../new_module&lt;br /&gt;
** .../new_module/langs&lt;br /&gt;
*** en-GB.mod_yourmodule.ini&lt;br /&gt;
*** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
*** anyother-language.mod_yourmodule.in&lt;br /&gt;
*** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
** .../new_module/language&lt;br /&gt;
*** .../new_module/language/en-GB&lt;br /&gt;
**** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
*** .../new_module/language/anyother-language&lt;br /&gt;
**** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
** .../new_module/tmpl&lt;br /&gt;
*** default.php&lt;br /&gt;
** mod_yourmodule.php&lt;br /&gt;
** mod_yourmodule.xml&lt;br /&gt;
&lt;br /&gt;
As a last step we&#039;ll edit the .../new_module/language/en-GB/mod_yourmodule.sys.ini to show a different message at installation/upgrade.&lt;br /&gt;
&lt;br /&gt;
==== mod_yourmodule.sys.ini - Installation message ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MOD_YOURMODULE_XML_DESCRIPTION=&amp;quot;Thank you for installing / update the Your own module. This module displays an article text in a module position. To activate you go to the module manager and edit this module or create a new entry. Select the article you want to show. Please visit www.mysite.com for more information. If you like it please add a review on JED.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you edit the description text to include a &amp;quot;Thanks&amp;quot; and other informations only relevant directly after the installation / upgrade this is a trick to achieve this. Only .../new_module/langs/mod_yourmodule.sys.ini will be copied and used after the installation.&lt;br /&gt;
&lt;br /&gt;
You can find two short descriptions of alternative handling of the language files at the end of this page.&lt;br /&gt;
&lt;br /&gt;
Now we compress the files. The Zip type is recommended as it has native support by most systems. In Windows you go to the .../new_module folder. Mark the included folders and files, right click and choose {{rarr|Send to,ZIP compressed folder}}.&lt;br /&gt;
&lt;br /&gt;
Rename the .zip file to mod_yourmodule_1_0_0.zip i.e. including the version number. You should better move this file to another folder. It is easy forgotten NOT to include it, the next time you create a zipped file.&lt;br /&gt;
&lt;br /&gt;
You made a backup before starting the tutorial? Well, only in case of ...&lt;br /&gt;
&lt;br /&gt;
First you uninstall the module to get a complete new installation {{rarr|Extensions,Manager,Manage}} Look up the module. Filter e.g. Location = Site, Type=Module and/or name.&lt;br /&gt;
&lt;br /&gt;
When the module is uninstalled you go to Install, browse to your installation zip file and click the Upload &amp;amp;amp; Install button. You&#039;ll see the description you edited as installation message. Go to the Module Manager. This time you should find an entry in the Module list. Choose this and enable it, as you did after the Discover in the first part of the tutorial. You can also see that the description is the one from your .ini file. To check the description from .sys.ini click on NEW module. This is not the one you saw directly after the installation.&lt;br /&gt;
&lt;br /&gt;
That&#039;s it for this part of the module tutorial. The next part will show you how to retrieve data and add some Css styling to your module.&lt;br /&gt;
&lt;br /&gt;
=== Alternative language files  handling ===&lt;br /&gt;
&lt;br /&gt;
For both alternatives you have to add all language files to subfolders in the /language folder. Be aware of the folder name! &lt;br /&gt;
&lt;br /&gt;
You can use the language files from the /langs folder in the example above. Do not add a long description to the .sys.ini files, as it will be used for the module lists. Of course you have to remove the /langs folder, if you want to test by changing the example above.&lt;br /&gt;
&lt;br /&gt;
Resulting folder:&lt;br /&gt;
&lt;br /&gt;
* /language&lt;br /&gt;
**/language/en-GB&lt;br /&gt;
*** en-GB.mod_yourmodule.ini&lt;br /&gt;
*** en-GB.mod_yourmodule.sys.ini&lt;br /&gt;
** /language/anyother-language&lt;br /&gt;
*** anyother-language.mod_yourmodule.ini&lt;br /&gt;
*** anyother-language.mod_yourmodule.sys.ini&lt;br /&gt;
&lt;br /&gt;
==== 1. Easiest way  ====&lt;br /&gt;
&lt;br /&gt;
Add a folder tag to the files area in the xml file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;folder&amp;gt;language&amp;lt;/folder&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The folder will be stored in the extensions folder and no files in the core language folder.&lt;br /&gt;
&lt;br /&gt;
==== 2. Traditional way  ====&lt;br /&gt;
&lt;br /&gt;
Add all single language files to the languages tag in the xml file. Be aware of the extra folder name required (= language tag).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;languages folder=&amp;quot;language&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;en-GB&amp;quot;&amp;gt;en-GB/en-GB.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.ini&amp;lt;/language&amp;gt;&lt;br /&gt;
      &amp;lt;language tag=&amp;quot;xx-YY&amp;quot;&amp;gt;xx-YY/xx-YY.mod_yourmodule.sys.ini&amp;lt;/language&amp;gt; &lt;br /&gt;
  &amp;lt;/languages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The files are saved the core language folder in the traditional way.&lt;/div&gt;</summary>
		<author><name>Over</name></author>
	</entry>
</feed>