Quick links: Content - sections - sub sections
EN FR

Trace:

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:tutorials:minitutorial [2007/09/16 06:30] – created laurenten:tutorials:minitutorial [2024/04/27 20:43] (current) – [Mini Tutorial] laurent
Line 1: Line 1:
 +~~LANG:FR@fr:tutoriels:minitutoriel~~
 +
 ====== Mini Tutorial ====== ====== Mini Tutorial ======
  
-The goal of this tutorial is to quickly show you how you can realize an application. To start, install Jelix as indicated on the [[en:manual:installation|installation]] pageWe will consider that you are using the default configuration, then you didn't modify the tree structure of Jelix.+  * [[en:tutorials:minitutorial:1.8.x|Mini tutorial for Jelix 1.8]]
  
 +For old jelix version which are unmaintained:
  
 +  * [[en:tutorials:minitutorial:1.7.x|Mini tutorial for Jelix 1.7]]
 +  * [[en:tutorials:minitutorial:1.6.x|Mini tutorial for Jelix 1.6]]
 +  * [[en:tutorials:minitutorial:1.5.x|Mini tutorial for Jelix 1.5]]
 +  * [[en:tutorials:minitutorial:1.3.x|Mini tutorial for Jelix 1.3]]
 +  * [[en:tutorials:minitutorial:1.2.x|Mini tutorial for Jelix 1.2]]
 +  * [[en:tutorials:minitutorial:1.1.x|Mini tutorial for Jelix 1.1]]
 +  * [[en:tutorials:minitutorial:1.0.x|Mini tutorial for Jelix 1.0]]
  
-===== Jelix scripts ===== 
- 
-After that, open a console and go to the lib/jelix-scripts/ directory. 
- 
-<code bash> 
-   cd lib/jelix-scripts/        # under linux 
-   cd lib\jelix-scripts\        # under windows  
-</code> 
- 
-This directory contains a script, jelix.php, which can make easy the creation and modification of different files of an application based on Jelix. You have to use it with the command line version of PHP and give it as parameter a Jelix command with some other parameters and options. 
- 
-<code bash> 
-php jelix.php [--application_name] command_name [options] [parameters] 
-</code> 
- 
-To avoid giving the name of the application for each command, use this one : 
- 
-<code bash> 
-  export JELIX_APP_NAME=helloapp        # under linux 
-  set JELIX_APP_NAME=helloapp           # under windows  
-</code> 
- 
- 
-===== Creation of an application ===== 
- 
-Let's create the tree structure of the application using the createapp command : 
- 
-<code bash> 
-php jelix.php createapp 
-</code> 
- 
-You will then get a helloapp/ directory, at the same level as the lib/ directory. Its content is the following : 
- 
-  helloapp/ 
-     modules/       the modules of your application 
-     plugins/       the plugins of your application 
-     var/config/    the configuration files of your application 
-     var/log/       the log files 
-     var/themes/    the different possible themes in your application 
-     var/overloads/  will contain the different files that you will redefine, from other modules.  
-     www/           the root of the site 
- 
- 
- 
-===== 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 "hello" : 
- 
-<code bash> 
-php jelix.php createmodule hello 
-</code> 
- 
-Here is the directory which has been created : 
- 
-   helloapp/modules/ 
-              hello/                the directory of the module 
-                module.xml          file describing the identity of the module 
-                controllers/       the classes processing the actions 
-                   default.classic.php   a default controller 
-                classes/            your business classes and services 
-                daos/               the object-relational mapping files 
-                locales/            locales files ("properties files") 
-                    en_EN/ 
-                    fr_FR/ 
-                templates/          templates of the module 
-                zones/              objects processing specific zones in a page 
- 
- 
- 
-===== Action implementation ===== 
- 
-Let's implement a default action. Open the controllers/default.classic.php file and modify the content this way : 
- 
-<code php> 
-class defaultCtrl extends jController { 
- 
-   function index () { 
-      $rep = $this->getResponse('html'); 
- 
-      return $rep; 
-   } 
-} 
-</code> 
- 
-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 <head> part of HTML, from some of its properties. Let's define the title of the page : 
- 
-<code php> 
-   $rep->title = 'Hello World !'; 
-</code> 
- 
-The body of the page is generated by default from 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->bodyTpl = 'hello'; 
-</code> 
- 
-We don't put the ".tpl" part because the content of the string is actually a Jelix //selector//. A Jelix selector is a link made to be able to refer to a resource of a module. 
- 
- 
-==== The template ==== 
- 
-Create a hello.tpl file in the template directory of the module. And put in this content : 
- 
-<code xml> 
-  <h2>Hello {$name} !</h2> 
-  <p>Welcome in Jelix !</p> 
-</code> 
- 
-"{$name}" is a template variable : it will be replaced by the value you will define, like in this example :  
- 
-<code php> 
-      $rep->body->assign('name','Me'); 
-</code> 
- 
- 
- 
-==== As a summary ==== 
-The code of the controller must now be like this : 
- 
-<code php> 
-class defaultCtrl extends jController { 
- 
-   function index () { 
-      $rep = $this->getResponse('html'); 
-      $rep->title = 'Hello World !'; 
-       
-      $rep->bodyTpl = 'hello'; 
-      $rep->body->assign('name','Me'); 
-     
-      return $rep; 
-   } 
-} 
-</code> 
- 
- 
- 
-===== First display ===== 
- 
-We are now ready to display our page. For this, give the following URL : 
-  http://localhost/jelix/helloapp/www/index.php?module=hello&action=default_index 
- 
-You will then see your html page, with the welcome message. 
- 
-The url can change regarding the configuration of your installation, especially if you have specified the document root of the site on the directory helloapp/www. You have to know that Jelix can handle the significant url to avoid all this disgusting parameters.  
- 
- 
- 
-===== Retrieving parameters ===== 
- 
-It would be interesting to be able to indicate as parameter of the url, the name to display in the template. 
- 
-<code php> 
-   $name = $this->param('name'); 
-   $rep->body->assign('name', $name); 
-</code> 
- 
-Now type : 
-    http://localhost/jelix/helloapp/www/index.php?module=hello&action=default_index&name=Robert 
  
 ----- -----
    * Go back to the [[en:documentation|documentation]]    * Go back to the [[en:documentation|documentation]]
-   * Continue to discover Jelix with the [[en:tutorials:main|main tutorial]]+
  

en/tutorials/minitutorial.1189924242.txt.gz · Last modified: 2007/09/17 22:42 (external edit)

Recent changes RSS feed Creative Commons License