Skip to content

CodeCorner3

leithoff edited this page Jul 8, 2016 · 25 revisions

Wiki ▸ [Developer Docs](Developer Docs) ▸ [Code Corner](Code Corner) ▸ day threea day in between


on day three we went out of base camp eGroupware and stepped into the high fields of ((eTemplate))s.
 

Motivation

  • splitting design and layout
  • there is no EGroupware specific dialog-editor (one part of the etemplate-app) to create the eTemplate but a EGroupware specific DTD. So any XML-Capable Editor will do.
  • Documenttypedefinition (DTD): <!DOCTYPE overlay PUBLIC "-//Stylite AG//eTemplate 2//EN" "http://www.egroupware.org/etemplate2.dtd"> Always add that to your .xet files
  • XSS security
  • no parsing of $_POST needed
  • eTemplates can be (and are usually) nested, eg. a template-field can contain an other eTemplate
  • language independent interfacing: each field / cell of the template can have a label which is automaticaly run through lang() (the content of the field can be run through lang() too)
  • they can have further keys, on loading the class picks the most appropriate one for a user
  • templates of an app are usually stored for distribution in app/templates/default
 

How to Setup our application the eGroupware way

Lets consider we want to rebuild our old flagship test. Remember the folderstructure?!
 
test                                    that has to be identical to our app-name
        + setup                         files necessary for the setup Programm, give the webserver write-permission to that dir (on a development box only!)
        + inc                           class-files
        + templates                     templates, still needed to store the images and get around a lot of complains from the api
                + default
                        + images        here goes our images / icons


The optional file setup.inc.php in folder $app/setup?
$app/setup/setup.inc.php should contain the information to setup your application.
 
<?php
        $setup_info['test']['name']      = 'test';
        $setup_info['test']['title']     = 'Test';
        $setup_info['test']['version']   = '0.9.001';  //anything you like, as long as it is fitting the schema of a version number
        $setup_info['test']['app_order'] = 100;        // at the end
        // $setup_info['test']['tables']    = array('egw_test'); // if there are any
        $setup_info['test']['enable']    = 1;
    /* Dependencies for this app to work */
    // if you define dependencies, you MUST meet them to get that baby on the road
$setup_info['test']['depends'][] = array(
	'appname'  => 'api',
	'versions' => Array('16.1')
);


Since we had our original application registered manually, we should unregister our baby, to avoid version-number conflicts that may occur, since the manually registered application had no ((VersionNumbers|version number)) at all.
So
  • unregister the manually registered test application
  • log out of eGroupware
  • enter the setup of eGroupware in egroupware/setup
  • enter the required login information at Setup/Config Admin Login
  • check with the Step 4 - Advanced Application Management
  • click on Manage Applications
  • look for our test application, check with install
  • click on Save
  • if there are any errors, and there should be none (if you use eGroupware 1.3.012), ...
    • try to fix them.
  • log out
  • Go back to user-login
  • Apply sufficient rights for the application (This is done via the Admin dialog within eGroupware.)
  • call the test application.
It is still there nothing changed so far exept the way we handle the setup.
With the setup.inc.php we tell eGroupware how to handle our application, apply VersionNumbers and all the other fancy stuff we might need later on.
 

Creating an eTemplate for the dialog

Now we need a nice edit dialog and use an editor of our choice to do that.
Assume that we wanted to name our first eTemplate index.
 
Step 1
create a file ```index.xet``` in the ```templates/default``` directory of our app ```test```. ... ```test/templates/default/index.xet``` .
 
Step 2
Enter the basics: ``` ```
 
Step 3
put in the basic template structure as it is used througout EGroupware ```xml
Clone this wiki locally