<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://docs.joomla.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://docs.joomla.org/index.php?title=Implementing_existing_scripts_into_Joomla_1.0&amp;feed=atom&amp;action=history</id>
		<title>Implementing existing scripts into Joomla 1.0 - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://docs.joomla.org/index.php?title=Implementing_existing_scripts_into_Joomla_1.0&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://docs.joomla.org/index.php?title=Implementing_existing_scripts_into_Joomla_1.0&amp;action=history"/>
		<updated>2013-05-26T09:36:08Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.19.3</generator>

	<entry>
		<id>http://docs.joomla.org/index.php?title=Implementing_existing_scripts_into_Joomla_1.0&amp;diff=34924&amp;oldid=prev</id>
		<title>Mvangeest: Added category and adjusted layout</title>
		<link rel="alternate" type="text/html" href="http://docs.joomla.org/index.php?title=Implementing_existing_scripts_into_Joomla_1.0&amp;diff=34924&amp;oldid=prev"/>
				<updated>2011-01-15T14:13:31Z</updated>
		
		<summary type="html">&lt;p&gt;Added category and adjusted layout&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr valign='top'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 14:13, 15 January 2011&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;======Implementing existing scripts into Joomla! &lt;/del&gt;1.0 &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;(WIP)======&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;{{JVer|&lt;/ins&gt;1.0&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;{{incomplete}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;So you decided to go Joomla, but have older PHP scripts you need to rescue over to your new site. This guide should help you to take the first steps.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;So you decided to go Joomla, but have older PHP scripts you need to rescue over to your new site. This guide should help you to take the first steps.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;==&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;===1. &lt;/del&gt;What do I want?&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;===&lt;/del&gt;==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;==What do I want?==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;In Joomla there are three kinds of add-ons. There are the modules, like the &amp;quot;Latest News&amp;quot; on your frontpage (When you installed the sample data), the plugins (formerly known as mambots), like the mosimage-plugin, that fills in images into your text. And the last and probably most important onces are the components, which we are going to deal with in this guide. Components output the main content on your site, like articles and news. We recommend to start with a component and if needed, work your way &amp;quot;up&amp;quot;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;In Joomla there are three kinds of add-ons. There are the modules, like the &amp;quot;Latest News&amp;quot; on your frontpage (When you installed the sample data), the plugins (formerly known as mambots), like the mosimage-plugin, that fills in images into your text. And the last and probably most important onces are the components, which we are going to deal with in this guide. Components output the main content on your site, like articles and news. We recommend to start with a component and if needed, work your way &amp;quot;up&amp;quot;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;==&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;===2. &lt;/del&gt;Why should I first create a component?&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;===&lt;/del&gt;==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;==Why should I first create a component?==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Components are very easy to create and they are the one thing that is called directly in the Joomla URL. Look at the URL of your Joomla page and notice the &amp;quot;option=com_something&amp;quot; behind the &amp;quot;index.php?&amp;quot;. This tells Joomla which component to load. If you have an URL like &amp;quot;index.php?option=com_content&amp;quot;, Joomla knows you want to open the component com_content. Joomla now prepares the parts around your content-area (HTML-header, menu, grafics, CSS) and loads your component. Everything after that, is purely in your hands.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Components are very easy to create and they are the one thing that is called directly in the Joomla URL. Look at the URL of your Joomla page and notice the &amp;quot;option=com_something&amp;quot; behind the &amp;quot;index.php?&amp;quot;. This tells Joomla which component to load. If you have an URL like &amp;quot;index.php?option=com_content&amp;quot;, Joomla knows you want to open the component com_content. Joomla now prepares the parts around your content-area (HTML-header, menu, grafics, CSS) and loads your component. Everything after that, is purely in your hands.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;==&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;===3. &lt;/del&gt;How should I start?&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;===&lt;/del&gt;==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;==How should I start?==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now, Joomla has a few rules we should pay attention to. First, there is the naming scheme. When you have this URL with the part &amp;quot;option=com_content&amp;quot;, Joomla searches for the folder com_content in the folder components. Depending wether you are in the backend or frontend, Joomla either uses your root Joomla components-directory or the one situated in the /administrator folder. When it has found the folder, it looks if it can find a file content.php in that folder (admin.content.php in the backend). You have to have this folder and this file to make it all work. You can include whatever file you want once inside this content.php. So to create a simple component, we just have to save the following code into a file with the name &amp;quot;hello.php&amp;quot; in the folder /components/com_hello:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now, Joomla has a few rules we should pay attention to. First, there is the naming scheme. When you have this URL with the part &amp;quot;option=com_content&amp;quot;, Joomla searches for the folder com_content in the folder components. Depending wether you are in the backend or frontend, Joomla either uses your root Joomla components-directory or the one situated in the /administrator folder. When it has found the folder, it looks if it can find a file content.php in that folder (admin.content.php in the backend). You have to have this folder and this file to make it all work. You can include whatever file you want once inside this content.php. So to create a simple component, we just have to save the following code into a file with the name &amp;quot;hello.php&amp;quot; in the folder /components/com_hello:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 17:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 19:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now we can call this component with &amp;quot;www.example.com/index.php?option=com_hello&amp;quot; and we get a nice page with &amp;quot;hello world.&amp;quot; printed in the area normally occupied by our content.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now we can call this component with &amp;quot;www.example.com/index.php?option=com_hello&amp;quot; and we get a nice page with &amp;quot;hello world.&amp;quot; printed in the area normally occupied by our content.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;==&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;===4. &lt;/del&gt;More rules&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;===&lt;/del&gt;==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;==More rules==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The following is not entirely necessary, but it will give your code more structure (hopefully) and make it easier for people (and yourself) to get through even big code blocks.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The following is not entirely necessary, but it will give your code more structure (hopefully) and make it easier for people (and yourself) to get through even big code blocks.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Joomla has established splitting the code from the logic quite some time ago and we encourage you to follow our example. At the moment there are two ways to achieve this. This means in our com_hello-example, we create the file &amp;quot;hello.html.php&amp;quot;:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Joomla has established splitting the code from the logic quite some time ago and we encourage you to follow our example. At the moment there are two ways to achieve this. This means in our com_hello-example, we create the file &amp;quot;hello.html.php&amp;quot;:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 45:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 47:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;You'll notice several things here. For one, we are checking if the variable _VALID_MOS is set to restrict possible attempts to execute this file from outside the Joomla-framework. Second we include the hello.html.php with the require_once-command. The function in the brackets gets the path and filename for the .html.php of the currently requested component. At last we call the function hello in the class we defined in &amp;quot;hello.html.php&amp;quot;. We still have the same output, but now we have separated the output from our (possible) logic.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;You'll notice several things here. For one, we are checking if the variable _VALID_MOS is set to restrict possible attempts to execute this file from outside the Joomla-framework. Second we include the hello.html.php with the require_once-command. The function in the brackets gets the path and filename for the .html.php of the currently requested component. At last we call the function hello in the class we defined in &amp;quot;hello.html.php&amp;quot;. We still have the same output, but now we have separated the output from our (possible) logic.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;==&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;===5. &lt;/del&gt;Getting really started&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;===&lt;/del&gt;==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;==Getting really started==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Ok, now we know some basics about Joomla and how it includes the components. Since you got your script allready running and just want to convert it to a component in Joomla, we cut the crap and get to the part thats important to you.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Ok, now we know some basics about Joomla and how it includes the components. Since you got your script allready running and just want to convert it to a component in Joomla, we cut the crap and get to the part thats important to you.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;===&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;=5.1 &lt;/del&gt;The database&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;=&lt;/del&gt;===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;===The database===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Joomla has a nice database abstraction layer, that makes usage much more simple. You don't have to worry about the login/password for your db and it makes usage with other Joomla-installations with different table-prefixes very easy. Take a look at the following code:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Joomla has a nice database abstraction layer, that makes usage much more simple. You don't have to worry about the login/password for your db and it makes usage with other Joomla-installations with different table-prefixes very easy. Take a look at the following code:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 60:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 62:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;In this function read_db, we first load the global $database and then prepare our query. Notice that the tablename is written with an &amp;lt;nowiki&amp;gt;#__&amp;lt;/nowiki&amp;gt; (double underscore!!). This is replaced with the correct table-prefix of the current Joomla-installation in the next step, when you set the query to be executed. In the third and last command, the result of the query is saved in the variable $result. The function $database-&amp;gt;loadResult() loads only the first value of the first row of a result. If you need more, you should take a look at the file database.php in the folder /includes in Joomla 1.0 or /libraries/joomla/database for Joomla 1.1. There are several functions that return arrays of the first row, arrays of the complete result, arrays of the first value in each row and so on....&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;In this function read_db, we first load the global $database and then prepare our query. Notice that the tablename is written with an &amp;lt;nowiki&amp;gt;#__&amp;lt;/nowiki&amp;gt; (double underscore!!). This is replaced with the correct table-prefix of the current Joomla-installation in the next step, when you set the query to be executed. In the third and last command, the result of the query is saved in the variable $result. The function $database-&amp;gt;loadResult() loads only the first value of the first row of a result. If you need more, you should take a look at the file database.php in the folder /includes in Joomla 1.0 or /libraries/joomla/database for Joomla 1.1. There are several functions that return arrays of the first row, arrays of the complete result, arrays of the first value in each row and so on....&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;===&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;=5.2 &lt;/del&gt;Getting user-values&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;=&lt;/del&gt;===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;===Getting user-values===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Since the normal $_POST poses a possible risk for code injection, Joomla provides you with the function mosGetParam(). mosGetParam() retrieves values from the user and filters them for malicious code.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Since the normal $_POST poses a possible risk for code injection, Joomla provides you with the function mosGetParam(). mosGetParam() retrieves values from the user and filters them for malicious code.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 67:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 69:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Here you see two examples of the usage of mosGetParam(). mosGetParam searches in the global variable defined in the first parameter and it searches for the value-name defined in the second parameter. The third parameter is optional and defines a default value, when the value hasn't been found.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Here you see two examples of the usage of mosGetParam(). mosGetParam searches in the global variable defined in the first parameter and it searches for the value-name defined in the second parameter. The third parameter is optional and defines a default value, when the value hasn't been found.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;===&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;=5.3 &lt;/del&gt;Getting those values back to my script&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;=&lt;/del&gt;===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;===Getting those values back to my script===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Most people have problems when starting to develop something in Joomla, that when they send their form, they don't get the values back into their code and are returned to the Joomla homepage. This is due to a missing input-field in your form. Remember the talk about how Joomla recognizes which component to load? We still have to tell it, that we want our component to handle the input. Therefore we have to put this somewhere inside our form:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Most people have problems when starting to develop something in Joomla, that when they send their form, they don't get the values back into their code and are returned to the Joomla homepage. This is due to a missing input-field in your form. Remember the talk about how Joomla recognizes which component to load? We still have to tell it, that we want our component to handle the input. Therefore we have to put this somewhere inside our form:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;php&lt;/del&gt;&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;html4strict&lt;/ins&gt;&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;option&amp;quot; value=&amp;quot;com_hello&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;option&amp;quot; value=&amp;quot;com_hello&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now Joomla calls our component again and we can handle that data we wanted from our user.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now Joomla calls our component again and we can handle that data we wanted from our user.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;==&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;===6. &lt;/del&gt;Calling different scripts in Joomla&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;===&lt;/del&gt;==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;==Calling different scripts in Joomla==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now we've changed a lot of our database and variable-retrieving code, but we still don't know how to properly call our different script-files our former script consists of.\\&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now we've changed a lot of our database and variable-retrieving code, but we still don't know how to properly call our different script-files our former script consists of.\\&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you have more than just one file in your script, you seem to have a problem calling those inside of Joomla. Joomla uses a case switching for this:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you have more than just one file in your script, you seem to have a problem calling those inside of Joomla. Joomla uses a case switching for this:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 100:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 102:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;As you can see, we first read the value of the POST-variable &amp;quot;task&amp;quot; and then differentiate between the different tasks at hand. When we find our correct task, we link to the file with the corresponding code. You could also link to a function, which would reduce the number of files in your components-folder and gives you the chance to easily call, for example, the view-function after saving your data.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;As you can see, we first read the value of the POST-variable &amp;quot;task&amp;quot; and then differentiate between the different tasks at hand. When we find our correct task, we link to the file with the corresponding code. You could also link to a function, which would reduce the number of files in your components-folder and gives you the chance to easily call, for example, the view-function after saving your data.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;==&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;===7. &lt;/del&gt;Creating my installation-package&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;===&lt;/del&gt;==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;==Creating my installation-package==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now we have (more or less) working code and want to install it in Joomla. Therefore we create an .xml-file with the necessary commands to prepare everything for our script:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now we have (more or less) working code and want to install it in Joomla. Therefore we create an .xml-file with the necessary commands to prepare everything for our script:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;php&lt;/del&gt;&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;xml&lt;/ins&gt;&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; ?&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; ?&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;mosinstall type=&amp;quot;component&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;mosinstall type=&amp;quot;component&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 134:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 136:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/mosinstall&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/mosinstall&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;You can see, we have some trivia about our component at the beginning, then we copy some files, execute a few querys and then we install the administrative part of the component. A little notice: The string between the &amp;lt;name&amp;gt;&amp;lt;/name&amp;gt;-tags is part of the folder your component-files are copied to. Joomla extends it with the prefix com_, so in case of our hello-script, the files would be copied into the folder com_hello. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;\\ \\&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;You can see, we have some trivia about our component at the beginning, then we copy some files, execute a few querys and then we install the administrative part of the component. A little notice: The string between the &amp;lt;name&amp;gt;&amp;lt;/name&amp;gt;-tags is part of the folder your component-files are copied to. Joomla extends it with the prefix com_, so in case of our hello-script, the files would be copied into the folder com_hello.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[:&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;start|Back to the Startpage&lt;/del&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Category&lt;/ins&gt;:&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Tutorials]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[[Category:Development&lt;/ins&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Mvangeest</name></author>	</entry>

	<entry>
		<id>http://docs.joomla.org/index.php?title=Implementing_existing_scripts_into_Joomla_1.0&amp;diff=34922&amp;oldid=prev</id>
		<title>Mvangeest: Tutorial:Implementing existing scripts into Joomla 1.0 WIP moved to Implementing existing scripts into Joomla 1.0: Moved page to main namespace because the Tutorial namespace is deprecated</title>
		<link rel="alternate" type="text/html" href="http://docs.joomla.org/index.php?title=Implementing_existing_scripts_into_Joomla_1.0&amp;diff=34922&amp;oldid=prev"/>
				<updated>2011-01-15T14:09:14Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;a href=&quot;/index.php?title=Tutorials:Implementing_existing_scripts_into_Joomla_1.0_WIP&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Tutorials:Implementing existing scripts into Joomla 1.0 WIP (page does not exist)&quot;&gt;Tutorial:Implementing existing scripts into Joomla 1.0 WIP&lt;/a&gt; moved to &lt;a href=&quot;/Implementing_existing_scripts_into_Joomla_1.0&quot; title=&quot;Implementing existing scripts into Joomla 1.0&quot;&gt;Implementing existing scripts into Joomla 1.0&lt;/a&gt;: Moved page to main namespace because the Tutorial namespace is deprecated&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
			&lt;tr valign='top'&gt;
			&lt;td colspan='1' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='1' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 14:09, 15 January 2011&lt;/td&gt;
			&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Mvangeest</name></author>	</entry>

	<entry>
		<id>http://docs.joomla.org/index.php?title=Implementing_existing_scripts_into_Joomla_1.0&amp;diff=6664&amp;oldid=prev</id>
		<title>Maintenance script: Importing text file</title>
		<link rel="alternate" type="text/html" href="http://docs.joomla.org/index.php?title=Implementing_existing_scripts_into_Joomla_1.0&amp;diff=6664&amp;oldid=prev"/>
				<updated>2008-05-10T01:17:00Z</updated>
		
		<summary type="html">&lt;p&gt;Importing text file&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr valign='top'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 01:17, 10 May 2008&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 10:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 10:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=====3. How should I start?=====&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=====3. How should I start?=====&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now, Joomla has a few rules we should pay attention to. First, there is the naming scheme. When you have this URL with the part &amp;quot;option=com_content&amp;quot;, Joomla searches for the folder com_content in the folder components. Depending wether you are in the backend or frontend, Joomla either uses your root Joomla components-directory or the one situated in the /administrator folder. When it has found the folder, it looks if it can find a file content.php in that folder (admin.content.php in the backend). You have to have this folder and this file to make it all work. You can include whatever file you want once inside this content.php. So to create a simple component, we just have to save the following code into a file with the name &amp;quot;hello.php&amp;quot; in the folder /components/com_hello:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now, Joomla has a few rules we should pay attention to. First, there is the naming scheme. When you have this URL with the part &amp;quot;option=com_content&amp;quot;, Joomla searches for the folder com_content in the folder components. Depending wether you are in the backend or frontend, Joomla either uses your root Joomla components-directory or the one situated in the /administrator folder. When it has found the folder, it looks if it can find a file content.php in that folder (admin.content.php in the backend). You have to have this folder and this file to make it all work. You can include whatever file you want once inside this content.php. So to create a simple component, we just have to save the following code into a file with the name &amp;quot;hello.php&amp;quot; in the folder /components/com_hello:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;lang=&amp;quot;php&amp;quot;&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;?php&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;?php&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;echo &amp;quot;hello world.&amp;quot;;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;echo &amp;quot;hello world.&amp;quot;;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 20:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 20:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The following is not entirely necessary, but it will give your code more structure (hopefully) and make it easier for people (and yourself) to get through even big code blocks.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;The following is not entirely necessary, but it will give your code more structure (hopefully) and make it easier for people (and yourself) to get through even big code blocks.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Joomla has established splitting the code from the logic quite some time ago and we encourage you to follow our example. At the moment there are two ways to achieve this. This means in our com_hello-example, we create the file &amp;quot;hello.html.php&amp;quot;:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Joomla has established splitting the code from the logic quite some time ago and we encourage you to follow our example. At the moment there are two ways to achieve this. This means in our com_hello-example, we create the file &amp;quot;hello.html.php&amp;quot;:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;lang=&amp;quot;php&amp;quot;&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;?php&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;?php&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;class hello_HTML {&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;class hello_HTML {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 31:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 31:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now this file does the output for us, but Joomla doesn't know that, so we have to teach it this in our &amp;quot;hello.php&amp;quot;:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now this file does the output for us, but Joomla doesn't know that, so we have to teach it this in our &amp;quot;hello.php&amp;quot;:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;lang=&amp;quot;php&amp;quot;&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;?php&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;?php&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;//echo &amp;quot;hello&amp;quot;;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;//echo &amp;quot;hello&amp;quot;;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 50:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 50:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;====5.1 The database====&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;====5.1 The database====&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Joomla has a nice database abstraction layer, that makes usage much more simple. You don't have to worry about the login/password for your db and it makes usage with other Joomla-installations with different table-prefixes very easy. Take a look at the following code:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Joomla has a nice database abstraction layer, that makes usage much more simple. You don't have to worry about the login/password for your db and it makes usage with other Joomla-installations with different table-prefixes very easy. Take a look at the following code:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;lang=&amp;quot;php&amp;quot;&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;function read_db() {&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;function read_db() {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;global $database;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;global $database;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 62:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 62:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;====5.2 Getting user-values====&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;====5.2 Getting user-values====&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Since the normal $_POST poses a possible risk for code injection, Joomla provides you with the function mosGetParam(). mosGetParam() retrieves values from the user and filters them for malicious code.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Since the normal $_POST poses a possible risk for code injection, Joomla provides you with the function mosGetParam(). mosGetParam() retrieves values from the user and filters them for malicious code.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;lang=&amp;quot;php&amp;quot;&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;$task = mosGetParam($_REQUEST, 'task', '');&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;$task = mosGetParam($_REQUEST, 'task', '');&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;$other_stuff = mosGetParam($_POST, 'nothing', array( 0 ) );&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;$other_stuff = mosGetParam($_POST, 'nothing', array( 0 ) );&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 69:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 69:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;====5.3 Getting those values back to my script====&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;====5.3 Getting those values back to my script====&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Most people have problems when starting to develop something in Joomla, that when they send their form, they don't get the values back into their code and are returned to the Joomla homepage. This is due to a missing input-field in your form. Remember the talk about how Joomla recognizes which component to load? We still have to tell it, that we want our component to handle the input. Therefore we have to put this somewhere inside our form:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Most people have problems when starting to develop something in Joomla, that when they send their form, they don't get the values back into their code and are returned to the Joomla homepage. This is due to a missing input-field in your form. Remember the talk about how Joomla recognizes which component to load? We still have to tell it, that we want our component to handle the input. Therefore we have to put this somewhere inside our form:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;lang=&amp;quot;php&amp;quot;&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;option&amp;quot; value=&amp;quot;com_hello&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;option&amp;quot; value=&amp;quot;com_hello&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 76:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 76:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now we've changed a lot of our database and variable-retrieving code, but we still don't know how to properly call our different script-files our former script consists of.\\&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now we've changed a lot of our database and variable-retrieving code, but we still don't know how to properly call our different script-files our former script consists of.\\&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you have more than just one file in your script, you seem to have a problem calling those inside of Joomla. Joomla uses a case switching for this:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;If you have more than just one file in your script, you seem to have a problem calling those inside of Joomla. Joomla uses a case switching for this:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;lang=&amp;quot;php&amp;quot;&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;?php&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;?php&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;// no direct access&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;// no direct access&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 102:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 102:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=====7. Creating my installation-package=====&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=====7. Creating my installation-package=====&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now we have (more or less) working code and want to install it in Joomla. Therefore we create an .xml-file with the necessary commands to prepare everything for our script:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Now we have (more or less) working code and want to install it in Joomla. Therefore we create an .xml-file with the necessary commands to prepare everything for our script:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;source &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;lang=&amp;quot;php&amp;quot;&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; ?&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; ?&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;mosinstall type=&amp;quot;component&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;mosinstall type=&amp;quot;component&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Maintenance script</name></author>	</entry>

	<entry>
		<id>http://docs.joomla.org/index.php?title=Implementing_existing_scripts_into_Joomla_1.0&amp;diff=6621&amp;oldid=prev</id>
		<title>Maintenance script: Importing text file</title>
		<link rel="alternate" type="text/html" href="http://docs.joomla.org/index.php?title=Implementing_existing_scripts_into_Joomla_1.0&amp;diff=6621&amp;oldid=prev"/>
				<updated>2008-05-10T01:12:40Z</updated>
		
		<summary type="html">&lt;p&gt;Importing text file&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;======Implementing existing scripts into Joomla! 1.0 (WIP)======&lt;br /&gt;
So you decided to go Joomla, but have older PHP scripts you need to rescue over to your new site. This guide should help you to take the first steps.&lt;br /&gt;
&lt;br /&gt;
=====1. What do I want?=====&lt;br /&gt;
In Joomla there are three kinds of add-ons. There are the modules, like the &amp;quot;Latest News&amp;quot; on your frontpage (When you installed the sample data), the plugins (formerly known as mambots), like the mosimage-plugin, that fills in images into your text. And the last and probably most important onces are the components, which we are going to deal with in this guide. Components output the main content on your site, like articles and news. We recommend to start with a component and if needed, work your way &amp;quot;up&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=====2. Why should I first create a component?=====&lt;br /&gt;
Components are very easy to create and they are the one thing that is called directly in the Joomla URL. Look at the URL of your Joomla page and notice the &amp;quot;option=com_something&amp;quot; behind the &amp;quot;index.php?&amp;quot;. This tells Joomla which component to load. If you have an URL like &amp;quot;index.php?option=com_content&amp;quot;, Joomla knows you want to open the component com_content. Joomla now prepares the parts around your content-area (HTML-header, menu, grafics, CSS) and loads your component. Everything after that, is purely in your hands.&lt;br /&gt;
&lt;br /&gt;
=====3. How should I start?=====&lt;br /&gt;
Now, Joomla has a few rules we should pay attention to. First, there is the naming scheme. When you have this URL with the part &amp;quot;option=com_content&amp;quot;, Joomla searches for the folder com_content in the folder components. Depending wether you are in the backend or frontend, Joomla either uses your root Joomla components-directory or the one situated in the /administrator folder. When it has found the folder, it looks if it can find a file content.php in that folder (admin.content.php in the backend). You have to have this folder and this file to make it all work. You can include whatever file you want once inside this content.php. So to create a simple component, we just have to save the following code into a file with the name &amp;quot;hello.php&amp;quot; in the folder /components/com_hello:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
echo &amp;quot;hello world.&amp;quot;;&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Now we can call this component with &amp;quot;www.example.com/index.php?option=com_hello&amp;quot; and we get a nice page with &amp;quot;hello world.&amp;quot; printed in the area normally occupied by our content.&lt;br /&gt;
&lt;br /&gt;
=====4. More rules=====&lt;br /&gt;
The following is not entirely necessary, but it will give your code more structure (hopefully) and make it easier for people (and yourself) to get through even big code blocks.&lt;br /&gt;
Joomla has established splitting the code from the logic quite some time ago and we encourage you to follow our example. At the moment there are two ways to achieve this. This means in our com_hello-example, we create the file &amp;quot;hello.html.php&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
class hello_HTML {&lt;br /&gt;
&lt;br /&gt;
function hello() {&lt;br /&gt;
echo &amp;quot;hello&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Now this file does the output for us, but Joomla doesn't know that, so we have to teach it this in our &amp;quot;hello.php&amp;quot;:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
//echo &amp;quot;hello&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// no direct access&lt;br /&gt;
defined( '_VALID_MOS' ) or die( 'Restricted access' );&lt;br /&gt;
&lt;br /&gt;
require_once( $mainframe-&amp;gt;getPath( 'front_html' ) );&lt;br /&gt;
&lt;br /&gt;
hello_HTML::hello();&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
You'll notice several things here. For one, we are checking if the variable _VALID_MOS is set to restrict possible attempts to execute this file from outside the Joomla-framework. Second we include the hello.html.php with the require_once-command. The function in the brackets gets the path and filename for the .html.php of the currently requested component. At last we call the function hello in the class we defined in &amp;quot;hello.html.php&amp;quot;. We still have the same output, but now we have separated the output from our (possible) logic.&lt;br /&gt;
&lt;br /&gt;
=====5. Getting really started=====&lt;br /&gt;
Ok, now we know some basics about Joomla and how it includes the components. Since you got your script allready running and just want to convert it to a component in Joomla, we cut the crap and get to the part thats important to you.&lt;br /&gt;
&lt;br /&gt;
====5.1 The database====&lt;br /&gt;
Joomla has a nice database abstraction layer, that makes usage much more simple. You don't have to worry about the login/password for your db and it makes usage with other Joomla-installations with different table-prefixes very easy. Take a look at the following code:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
function read_db() {&lt;br /&gt;
global $database;&lt;br /&gt;
&lt;br /&gt;
$query = &amp;quot;SELECT title FROM #__content WHERE id = 1&amp;quot;;&lt;br /&gt;
$database-&amp;gt;setQuery($query);&lt;br /&gt;
$result = $database-&amp;gt;loadResult();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
In this function read_db, we first load the global $database and then prepare our query. Notice that the tablename is written with an &amp;lt;nowiki&amp;gt;#__&amp;lt;/nowiki&amp;gt; (double underscore!!). This is replaced with the correct table-prefix of the current Joomla-installation in the next step, when you set the query to be executed. In the third and last command, the result of the query is saved in the variable $result. The function $database-&amp;gt;loadResult() loads only the first value of the first row of a result. If you need more, you should take a look at the file database.php in the folder /includes in Joomla 1.0 or /libraries/joomla/database for Joomla 1.1. There are several functions that return arrays of the first row, arrays of the complete result, arrays of the first value in each row and so on....&lt;br /&gt;
====5.2 Getting user-values====&lt;br /&gt;
Since the normal $_POST poses a possible risk for code injection, Joomla provides you with the function mosGetParam(). mosGetParam() retrieves values from the user and filters them for malicious code.&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
$task = mosGetParam($_REQUEST, 'task', '');&lt;br /&gt;
$other_stuff = mosGetParam($_POST, 'nothing', array( 0 ) );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here you see two examples of the usage of mosGetParam(). mosGetParam searches in the global variable defined in the first parameter and it searches for the value-name defined in the second parameter. The third parameter is optional and defines a default value, when the value hasn't been found.&lt;br /&gt;
====5.3 Getting those values back to my script====&lt;br /&gt;
Most people have problems when starting to develop something in Joomla, that when they send their form, they don't get the values back into their code and are returned to the Joomla homepage. This is due to a missing input-field in your form. Remember the talk about how Joomla recognizes which component to load? We still have to tell it, that we want our component to handle the input. Therefore we have to put this somewhere inside our form:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;option&amp;quot; value=&amp;quot;com_hello&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Now Joomla calls our component again and we can handle that data we wanted from our user.&lt;br /&gt;
=====6. Calling different scripts in Joomla=====&lt;br /&gt;
Now we've changed a lot of our database and variable-retrieving code, but we still don't know how to properly call our different script-files our former script consists of.\\&lt;br /&gt;
If you have more than just one file in your script, you seem to have a problem calling those inside of Joomla. Joomla uses a case switching for this:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
// no direct access&lt;br /&gt;
defined( '_VALID_MOS' ) or die( 'Restricted access' );&lt;br /&gt;
&lt;br /&gt;
require_once( $mainframe-&amp;gt;getPath( 'front_html' ) );&lt;br /&gt;
&lt;br /&gt;
$task = mosGetParam( $_REQUEST, 'task', 'view' );&lt;br /&gt;
switch ($task) {&lt;br /&gt;
case 'edit':&lt;br /&gt;
    include('edit.php');&lt;br /&gt;
    break;&lt;br /&gt;
case 'save':&lt;br /&gt;
    include('save.php');&lt;br /&gt;
    break;&lt;br /&gt;
case 'view':&lt;br /&gt;
default:&lt;br /&gt;
    include('view.php');&lt;br /&gt;
    break;&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
As you can see, we first read the value of the POST-variable &amp;quot;task&amp;quot; and then differentiate between the different tasks at hand. When we find our correct task, we link to the file with the corresponding code. You could also link to a function, which would reduce the number of files in your components-folder and gives you the chance to easily call, for example, the view-function after saving your data.&lt;br /&gt;
&lt;br /&gt;
=====7. Creating my installation-package=====&lt;br /&gt;
Now we have (more or less) working code and want to install it in Joomla. Therefore we create an .xml-file with the necessary commands to prepare everything for our script:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;mosinstall type=&amp;quot;component&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;name&amp;gt;hello&amp;lt;/name&amp;gt;&lt;br /&gt;
  &amp;lt;creationDate&amp;gt;07/02/06&amp;lt;/creationDate&amp;gt;&lt;br /&gt;
  &amp;lt;author&amp;gt;That scripting guy&amp;lt;/author&amp;gt;&lt;br /&gt;
  &amp;lt;copyright&amp;gt;This component is released under the GNU/GPL License&amp;lt;/copyright&amp;gt;&lt;br /&gt;
  &amp;lt;authorEmail&amp;gt;author@author.com&amp;lt;/authorEmail&amp;gt;&lt;br /&gt;
  &amp;lt;authorUrl&amp;gt;www.author.com&amp;lt;/authorUrl&amp;gt;&lt;br /&gt;
  &amp;lt;version&amp;gt;0.1&amp;lt;/version&amp;gt;&lt;br /&gt;
  &amp;lt;description&amp;gt;This is the installation-file for our script&amp;lt;/description&amp;gt;&lt;br /&gt;
  &amp;lt;files&amp;gt;&lt;br /&gt;
    &amp;lt;filename&amp;gt;hello.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
    &amp;lt;filename&amp;gt;hello.html.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
  &amp;lt;/files&amp;gt;&lt;br /&gt;
  &amp;lt;install&amp;gt;&lt;br /&gt;
    &amp;lt;queries&amp;gt;&lt;br /&gt;
	&amp;lt;query&amp;gt;&lt;br /&gt;
	CREATE #__hello (&lt;br /&gt;
        'hello' char(230) NOT NULL default ''&lt;br /&gt;
        ) Type=MyISAM;&lt;br /&gt;
	&amp;lt;/query&amp;gt;&lt;br /&gt;
    &amp;lt;/queries&amp;gt;&lt;br /&gt;
  &amp;lt;/install&amp;gt;&lt;br /&gt;
&amp;lt;administration&amp;gt;&lt;br /&gt;
&amp;lt;menu&amp;gt;Hello&amp;lt;/menu&amp;gt;&lt;br /&gt;
&amp;lt;files&amp;gt;&lt;br /&gt;
    &amp;lt;filename&amp;gt;admin.hello.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
&amp;lt;/files&amp;gt;&lt;br /&gt;
&amp;lt;/administration&amp;gt;&lt;br /&gt;
&amp;lt;/mosinstall&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
You can see, we have some trivia about our component at the beginning, then we copy some files, execute a few querys and then we install the administrative part of the component. A little notice: The string between the &amp;lt;name&amp;gt;&amp;lt;/name&amp;gt;-tags is part of the folder your component-files are copied to. Joomla extends it with the prefix com_, so in case of our hello-script, the files would be copied into the folder com_hello. \\ \\&lt;br /&gt;
&lt;br /&gt;
[[:start|Back to the Startpage]]&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>	</entry>

	</feed>