Newer
Older
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
Billie Holiday USA
Elvis Presley USA
Louis Armstrong USA
Diana Ross USA
More HTML::
10.sql = SELECT p.name FROM ExpPerson AS p
10.head = <ul>
10.tail = </ul>
10.rbeg = <li>
10.rend = </li>
Result::
o Billie Holiday
o Elvis Presley
o Louis Armstrong
o Diana Ross
The same as above, but with braces::
10 {
sql = SELECT p.name FROM ExpPerson AS p
head = <ul>
tail = </ul>
rbeg = <li>
rend = </li>
}
Two queries::
10.sql = SELECT p.name FROM ExpPerson AS p
10.rend = <br>
20.sql = SELECT a.street FROM ExpAddress AS a
20.rend = <br>
Two queries: nested::
# outer query
10.sql = SELECT p.name FROM ExpPerson AS p
10.rend = <br>
# inner query
10.10.sql = SELECT a.street FROM ExpAddress AS a
10.10.rend = <br>
* For every record of '10', all records of 10.10 will be printed.
Two queries: nested with variables::
# outer query
10.sql = SELECT p.id, p.name FROM ExpPerson AS p
10.rend = <br>
# inner query
10.10.sql = SELECT a.street FROM ExpAddress AS a WHERE a.pId='{{10.id}}'
10.10.rend = <br>
* For every record of '10', all assigned records of 10.10 will be printed.
Two queries: nested with hidden variables in a table::
10.sql = SELECT p.id AS _pId, p.name FROM ExpPerson AS p
10.rend = <br>
# inner query
10.10.sql = SELECT a.street FROM ExpAddress AS a WHERE a.pId='{{10.pId}}'
10.10.rend = <br>
Same as above, but written in the nested notation::
10 {
sql = SELECT p.id AS _pId, p.name FROM ExpPerson AS p
rend = <br>
10 {
# inner query
sql = SELECT a.street FROM ExpAddress AS a WHERE a.pId='{{10.pId}}'
rend = <br>
}
}
Best practice *recommendation* for using parameter - see :ref:`access-column-values`::
10 {
sql = SELECT p.id AS _pId, p.name FROM ExpPerson AS p
rend = <br>
10 {
# inner query
sql = SELECT a.street FROM ExpAddress AS a WHERE a.pId='{{pId:R}}'
rend = <br>
}
}
Create HTML tables. Each column is wrapped in ``<td>``, each row is wrapped in ``<tr>``::
10 {
sql = SELECT p.firstName, p.lastName, p.country FROM Person AS p
head = <table class="table">
tail = </table>
rbeg = <tr>
rend = </tr>
fbeg = <td>
fend = </td>
}
Maybe a few columns belongs together and should be in one table column.
Joining columns, variant A: firstName and lastName in one table column::
10 {
sql = SELECT CONCAT(p.firstName, ' ', p.lastName), p.country FROM Person AS p
head = <table class="table">
tail = </table>
rbeg = <tr>
rend = </tr>
fbeg = <td>
fend = </td>
}
Joining columns, variant B: firstName and lastName in one table column::
10 {
sql = SELECT '<td>', p.firstName, ' ', p.lastName, '</td><td>', p.country, '</td>' FROM Person AS p
head = <table class="table">
tail = </table>
rbeg = <tr>
rend = </tr>
}
Joining columns, variant C: firstName and lastName in one table column. Notice ``fbeg``, ``fend` and ``fskipwrap``::
10 {
sql = SELECT '<td>', p.firstName, ' ', p.lastName, '</td>', p.country FROM Person AS p
head = <table class="table">
tail = </table>
rbeg = <tr>
rend = </tr>
fbeg = <td>
fend = </td>
fskipwrap = 1,2,3,4,5
}
Joining columns, variant D: firstName and lastName in one table column. Notice ``fbeg``, ``fend` and ``fskipwrap``::
10 {
sql = SELECT CONCAT('<td>', p.firstName, ' ', p.lastName, '</td>') AS '_noWrap', p.country FROM Person AS p
head = <table class="table">
tail = </table>
rbeg = <tr>
rend = </tr>
fbeg = <td>
fend = </td>
}
Recent List
^^^^^^^^^^^
A nice feature is to show a list with last changed records. The following will show the 10 last modified (Form or
FormElement) forms::
10 {
sql = SELECT CONCAT('p:{{pageAlias:T}}&form=form&r=', f.id, '|t:', f.name,'|o:', GREATEST(MAX(fe.modified), f.modified)) AS _page
FROM Form AS f
LEFT JOIN FormElement AS fe
ON fe.formId = f.id
GROUP BY f.id
ORDER BY GREATEST(MAX(fe.modified), f.modified) DESC
LIMIT 10
head = <h3>Recent Forms</h3>
rsep = , 
}
.. _`vertical-column-title`:
Table: vertical column title
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To orientate a column title vertical, use the QFQ CSS classe `qfq-vertical` in td|th and `qfq-vertical-text` around the text.
HTML example (second column title is vertical)::
<table><thead>
<tr>
<th>horizontal</th>
<th class="qfq-vertical"><span class="qfq-vertical-text">text vertical</span></th>
</tr>
</thead></table>
QFQ example::
10 {
sql = SELECT title FROM Settings ORDER BY title
fbeg = <th class="qfq-vertical"><span class="qfq-vertical-text">
fend = </span></th>
head = <table><thead><tr>
rend = </tr></thead>
tail = </table>
20.sql = SELECT ...
}
.. _`store_user_examples`:
STORE_USER examples
^^^^^^^^^^^^^^^^^^^
Keep variables per user session.
Two pages (pass variable)
"""""""""""""""""""""""""
Sometimes it's useful to have variables per user (=browser session). Set a variable on page 'A' and retrieve the value
on page 'B'.
Page 'A' - set the variable::
10.sql = SELECT 'hello' AS '_=greeting'
Page 'B' - get the value::
10.sql = SELECT '{{greeting:UE}}'
If page 'A' has never been opened with the current browser session, nothing is printed (STORE_EMPTY gives an empty string).
If page 'A' is called, page 'B' will print 'hello'.
One page (collect variables)
""""""""""""""""""""""""""""
A page will be called with several SIP variables, but not at all at the same time. To still get all variables at any time::
# Normalize
10.sql = SELECT '{{order:USE:::sum}}' AS '_=order', '{{step:USE:::5}}' AS _step, '{{direction:USE:::ASC}}' AS _direction
# Different links
20.sql = SELECT 'p:{{pageAlias:T}}&order=count|t:Order by count|b|s' AS _link,
'p:{{pageAlias:T}}&order=sum|t:Order by sum|b|s' AS _link,
'p:{{pageAlias:T}}&step=10|t:Step=10|b|s' AS _link,
'p:{{pageAlias:T}}&step=50|t:Step=50|b|s' AS _link,
'p:{{pageAlias:T}}&direction=ASC|t:Order by up|b|s' AS _link,
'p:{{pageAlias:T}}&direction=DESC|t:Order by down|b|s' AS _link
30.sql = SELECT * FROM Items ORDER BY {{order:U}} {{direction:U}} LIMIT {{step:U}}
Simulate/switch user: feUser
""""""""""""""""""""""""""""
Just set the STORE_USER variable 'feUser'.
All places with `{{feUser:T}}` has to be replaced by `{{feUser:UT}}`::
# Normalize
10.sql = SELECT '{{feUser:UT}}' AS '_=feUser'
# Offer switching feUser
20.sql = SELECT 'p:{{pageAlias:T}}&feUser=account1|t:Become "account1"|b|s' AS _link,
'p:{{pageAlias:T}}&feUser={{feUser:T}}|t:Back to own identity|b|s' AS _link,
Semester switch (remember last choice)
""""""""""""""""""""""""""""""""""""""
A current semester is defined via configuration in STORE_SYSTEM '{{semId:Y}}'. The first column in 10.sql
`'{{semId:SUY}}' AS '_=semId'` saves
the semester to STORE_USER via '_=semId'. The priority 'SUY' takes either the latest choose (STORE_SIP) or reuse the
last used (STORE_USER) or (first time call during browser session) takes the default from config (STORE_SYSTEM)::
# Semester switch
10 {
sql = SELECT '{{semId:SUY}}' AS '_=semId'
, CONCAT('p:{{pageAlias:T}}&semId=', sp.id, '|t:', QBAR(sp.name), '|s|b|G:glyphicon-chevron-left') AS _link
, ' <button class="btn disabled ', IF({{semId:Y0}}=sc.id, 'btn-success', 'btn-default'), '">',sc.name, '</button> '
, CONCAT('p:{{pageAlias:T}}&semId=', sn.id, '|t:', QBAR(sn.name), '|s|b|G:glyphicon-chevron-right|R') AS _link
FROM Semester AS sc
LEFT JOIN semester AS sp
ON sp.id=sc.id-1
LEFT JOIN semester AS sn
ON sc.id+1=sn.id AND sn.show_semester_from<=CURDATE()
WHERE sc.id={{semId:SUY}}
ORDER BY sc.semester_von
head = <div class="btn-group" style="position: absolute; top: 15px; right: 25px;">
tail = </div><p></p>
}