- Tips
- No other pages in this book
Part: Tips
« Deploying a Jelix application | References » |
− Table of content
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.
$rep = $this->getResponse('html');
Retrieve current action ¶
Use this expression to retrieve current action in a controller, a zone, your common response.
jApp::coord()->action->toString();
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 $_SESSION['JELIX_USER'] variable :
$_SESSION['JELIX_USER']->login
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:
<property inserpattern="NOW()" .../>
your date field will be set to current date on record insert.
<property updatepattern="NOW()" .../>
your date field will be set to current date on record update.