Fork me on GitHub

Plugin sqlpage

Introduction

This plugin lets create pages with SQL statements and Freemarker HTML templates. Each page may contain one or more SQL fragments. Each fragment has its own HTML template.

Call an SQLPage in the Front Office

Call an SQLPage is very simple :

jsp/site/Portal.jsp?page=sqlpage&sqlpage=mypage[&param1=myparam1 ... &paramN=myparamN]

Optional parameters can be passed to be used by SQL queries.

Create SQLPage in the Back Office

Templates are using Freemarker Template Engine syntax.

Table sample

The query : SELECT first_name, last_name FROM core_admin_user

The template :

<table>
    <thead>
    <tr>
        <th>Firstname</th>
        <th>Lastname</th>
    </tr>
    </thead>
    <tbody>
        <#list rows as row>
            <tr>
               <td>${row.cols[0]}</td>
               <td>${row.cols[1]}</td>
            </tr>
        </#list>
    </tbody>
</table>

Form sample

The query : SELECT first_name, last_name FROM core_admin_user WHERE id_user = @param1@

This query shows how parameter given in the HTTP request can be used in the query.

The template :


<h1>User</h1>
Firstname : ${rows[0].cols[0]} <br>
Lastname : ${rows[0].cols[1]} <br>