Objectives

This tutorial will help you to develop your first page with copix. It introduces some concept of the framework.

Here, We'll anwser to the following url : index.php/default/hello/you. This URL can also be written under this form : index.php?group=hello&action=you

NB : If you want to know more about Copix URL, pleade read this page : "Understanding URL Format".

Introduction

In Copix, a "URL/page HTML" ... to an actions. These action are implemented in Actiongroups. Those Actiongroups are all extended from CopixActionGroup. Your developpement will be ever made in modules. For this tutorial, we will create elements in the default module, which took place in the project/module/public/standard/default directory.

Our first page

Create file project/module/public/stable/standard/default/actiongroups/hello.actiongroup.phpwith the following content :

<?php
   /**
    * Welcoming page and standard fonctionnality.
    * This object can standardly manage urls formated index.php/concernedModule/hello/xxxx
    */

    class ActionGroupHello extends CopixActionGroup {
        /**
         * Our first exemple
         * This methodes implements the index.php/moduleConcerné/hello/you url 
         */

        function processYou () {

        }
    }
?>

Implementing action

Thus, We wish to display a page with "hello you" inside.

function processYou () {
            $ppo = new CopixPPO ();//Creation of data object 
            $ppo->name = 'you';  // Assignating	value
            return _arPPO ($ppo, 'hello.tpl'); //  displaying datas
        }

Copix uses a MVC model? (Model View Controler)

Here, we will gives variables of the model in the "$ppo" variable (PPO is for Plain PHP Object) which is a simple object in order to conveys data

We'll give to the $ppo->name variable the value "you".valeur "you". Then, we'll indicate that we want to display data of $ppo variable in the hello.tpl template.

Creating template

Creates the file project/modules/public/stable/standard/default/templates/hello.tpl with the following content

Hello {$ppo->name}

Standardly, Copix uses the Smarty template engine. If you wish, you can directly write your template in PHP. In this case, you have to use folowing extensions ".ptpl" or ".php" and the code looks like this :

<p>Hello <?php echo $ppo->name; ?></p>