'''''[This is based on my experiments, I expect more knowledgeable people to jump in!]'''''

+

== How to Build Your First Joomla Platform Application ==

+

+

This article will allow you to create your first Joomla Platform application, following a step-by-step process outlined below. We’ll assume you’re in an environment that has access to PHP (Mac OS X has this by default), and that you’ve got a connection to the Internet to download the platform project.

+

+

'''Step 1: Download the latest Joomla Platform'''

+

+

Simply point your Web browser to http://github.com/joomla/joomla-platform and then click on the “Downloads” button. In the pop-up window that appears, click on either the “Download .tar.gz” button or the “Download .zip” button, depending on your preference.

+

+

'''Step 2: Extract the Joomla Platform in your own environment'''

+

+

After you’ve downloaded the file, extract it in the location of your choosing.

+

+

'''Step 3: Create a new file'''

+

+

Create a folder named ‘examples’ within the root directory where you extracted the Joomla Platform. Using your favorite text/code editor, copy/paste code from the following examples (one at a time) into a new file.

Using your favorite CLI (maybe Terminal on the Mac, or PuTTy on Windows), navigate to the ‘examples’ folder where you saved your file. Type “php helloword.php” (or whatever you named your file) and click the enter key on your keyboard.

+

+

'''Step 5: Read the result on your screen, savor the moment'''

+

+

'''Step 6: Tweet your success'''

+

+

Tell the world that you just made your first successful Joomla Platform app by tweeting the following: “OMG, I just wrote a #jplatform app! #joomla”

+

+

----

+

+

== Example Hello World Command Line Interface (CLI) App ==

+

+

<source lang="php">

+

<?php

+

define( '_JEXEC', 1 );

+

+

require_once ( '../libraries/import.php' );

+

jimport( 'joomla.application.cli' );

+

+

class HelloWorld extends JCli

+

{

+

+

public function execute( )

+

{

+

$this->out( 'Hello World' );

+

}

+

}

+

+

JCli::getInstance( 'HelloWorld' )->execute( );

+

</source>

+

+

+

----

+

+

+

'''''[Information below this point seems to be out of date, cleaning required]'''''

In order to use the Joomla! Framework alone, you would have to follow the following guidelines:

In order to use the Joomla! Framework alone, you would have to follow the following guidelines:

Revision as of 20:54, 7 August 2011

How to Build Your First Joomla Platform Application

This article will allow you to create your first Joomla Platform application, following a step-by-step process outlined below. We’ll assume you’re in an environment that has access to PHP (Mac OS X has this by default), and that you’ve got a connection to the Internet to download the platform project.

Step 1: Download the latest Joomla Platform

Simply point your Web browser to http://github.com/joomla/joomla-platform and then click on the “Downloads” button. In the pop-up window that appears, click on either the “Download .tar.gz” button or the “Download .zip” button, depending on your preference.

Step 2: Extract the Joomla Platform in your own environment

After you’ve downloaded the file, extract it in the location of your choosing.

Step 3: Create a new file

Create a folder named ‘examples’ within the root directory where you extracted the Joomla Platform. Using your favorite text/code editor, copy/paste code from the following examples (one at a time) into a new file.

Using your favorite CLI (maybe Terminal on the Mac, or PuTTy on Windows), navigate to the ‘examples’ folder where you saved your file. Type “php helloword.php” (or whatever you named your file) and click the enter key on your keyboard.

Step 5: Read the result on your screen, savor the moment

Step 6: Tweet your success

Tell the world that you just made your first successful Joomla Platform app by tweeting the following: “OMG, I just wrote a #jplatform app! #joomla”

Note: It is possible to use Joomla! framework without a database. To do that, pass a config array containing session as a key with the value of false in the call to JFactory::getApplication() like this:

After that, you can still use a file based authentication system if you want.

Use Existing Joomla Configuration in External PHP file

This Article is written by Andy@PCinvent.Net

Sometimes you may need to write an external Php file in stead of working in Joomla files. Outside the Joomla Framework, we can not use Joomla DB libraries, such as Global object $db, loadResult(), loadResultArray, loadAssocList, loadRow() and etc. In this case, we can use the custom PHP code plugin to write the code right in the Joomla content page. Or you can try what I do here: Include Joomla configuration and write your own MySQL queries in external php file...... Joomla Configuration If you open configuration.php, you will see that all variables inside are under the class JConfig(). In my example here, I need the variables of $host, $db, $user and $password Joomla page Suppose we have a Joomla page called "jm_page.php" in jm_page.php, I tried to POST a request variable of $user_id from "jm_page.php" to external php file called "external.php".

In the code I wrote below, the objective is to use Jconfig Class without re-giving Database connection strings which were already defined in Joomla Configuration page. Having the DB established, we query and output the first value in the $result Array. In the Query, I tried to get the result of sex of the user base on the user id from the table "jos_community_user".

How to read $jconfig->host? $Jconfig is now the instance of the Jconfig class. host is the variable $host inside the class.

<?php#### The following codes is written by Andy Ng <http://www.pcinvent.net> #### #### Please keep the above credit line to the Autor #### //get POST $user_id=$_POST["user_id"];echo$user_id;//use joomla db classrequire_once("configuration.php");$jconfig=new JConfig();//db establish $db_error="I am sorry! We are maintenaning the website, please try again later.";$db_config=mysql_connect($jconfig->host,$jconfig->user,$jconfig->password) or die($db_error);mysql_select_db($jconfig->db,$db_config) or die($db_error);//db query result $query="SELECT user_sex FROM jos_community_user WHERE user_id = $user_id";//get user_sex $query_execute=mysql_query($query);$result=mysql_fetch_row($query_execute);echo$result[0];mysql_close($db_config);//andy:close db for security reason ?>