-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtips.gtw
50 lines (31 loc) · 1.24 KB
/
tips.gtw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
~~LANG:FR@frman:astuces~~
===== Tips for common problems =====
This page gather snippets of code resolving common development problems.
==== Prevent some errors ====
Upon an html request, don't forget that line at the beginning of an action.
<code php>
$rep = $this->getResponse('html');
</code>
==== Retrieve current action ====
Use this expression to retrieve current action in a controller, a zone, your common response.
<code php>
jApp::coord()->action->toString();
</code>
==== Access user session variables ====
Jelix use PHP sessions by default. If you use jAuth, it stores user dao record
(data coming from jelix_user table) in a PHP session variable. Thus, user infos
are accessible through @@jAuth::getUserSession()@@:
<code php>
jAuth::getUserSession()->login
</code>
==== Store current date in database ====
This one applies to date fields having //datetime// or //date// as type.
Just add the following attributes to the property line associated with your date field and located in your DAO xml file:
<code xml>
<property inserpattern="NOW()" .../>
</code>
your date field will be set to current date on record insert.
<code xml>
<property updatepattern="NOW()" .../>
</code>
your date field will be set to current date on record update.