Trace:
Differences ¶
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
en:minitutorial [2006/09/14 15:54] – doubleface | en:minitutorial [2006/09/18 11:18] – doubleface | ||
---|---|---|---|
Line 24: | Line 24: | ||
set JELIX_APP_NAME=helloapp (windows) | set JELIX_APP_NAME=helloapp (windows) | ||
</ | </ | ||
+ | |||
Line 46: | Line 47: | ||
+ | |||
+ | ===== Creation of a module ===== | ||
+ | |||
+ | A module gathers a whole of actions. At least one is necessary in an application. Let's create our first module " | ||
+ | |||
+ | <code bash> | ||
+ | php jelix.php createmodule hello | ||
+ | </ | ||
+ | |||
+ | Here is the directory which has been created : | ||
+ | |||
+ | | ||
+ | hello/ | ||
+ | module.xml | ||
+ | controllers/ | ||
+ | | ||
+ | classes/ | ||
+ | daos/ the object-relational mapping files | ||
+ | locales/ | ||
+ | en_EN/ | ||
+ | fr_FR/ | ||
+ | templates/ | ||
+ | zones/ | ||
+ | |||
+ | |||
+ | |||
+ | ===== Action implementation ===== | ||
+ | |||
+ | Let's implement a default action. Open the controllers/ | ||
+ | |||
+ | <code php> | ||
+ | class CTDefault extends jController { | ||
+ | |||
+ | | ||
+ | $rep = $this-> | ||
+ | |||
+ | return $rep; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | We state here that we retrieve the jResponseHtml object (because of the HTML type as it is indicated), and we return it to indicate that its content must be returned to the browser. | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ==== Response object ==== | ||
+ | |||
+ | The jResponseHtml object generates a response in HTML (a HTML page). It generates automatically the < | ||
+ | |||
+ | <code php> | ||
+ | | ||
+ | </ | ||
+ | |||
+ | The body of the page is generated by default by a template, via an instance of the Jelix template engine, placed in the body property. The name of the template file is placed in the bodyTpl property. Here, it's the hello.tpl file. | ||
+ | |||
+ | <code php> | ||
+ | $rep-> | ||
+ | </ | ||
+ | |||
+ | We don't put the " | ||
+ | |||
+ | |||
+ | ==== The template ==== | ||
+ | |||
+ | Create a hello.tpl file in the template directory of the module. And put in this content : | ||
+ | |||
+ | <code xml> | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | " | ||
+ | |||
+ | <code php> | ||
+ | $rep-> | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ==== As a summary ==== | ||
+ | The code of the controller must now be like this : | ||
+ | |||
+ | <code php> | ||
+ | class CTDefault extends jController { | ||
+ | |||
+ | | ||
+ | $rep = $this-> | ||
+ | $rep-> | ||
+ | | ||
+ | $rep-> | ||
+ | $rep-> | ||
+ | | ||
+ | return $rep; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== First display ===== | ||
+ | |||
+ | We are now ready to display our page. For this, give the following URL : | ||
+ | http:// | ||
+ | |||
+ | You will then see your html page, with the welcome message. | ||
+ | |||
+ | The url can change regarding the configuration of your installation, |