All app types, except data apps, are supporting HTTP GET and HTTP POST parameters in:
- The default where clause of the Table Builder for data tables and data administration apps
- The default where clause of the Map Builder for maps
- The query specified for charts in the App Manager data source section
The variables listed below can be used as URL parameters:
- httpGet[‘param_name’]: Returns the value of parameter param_name for an HTTP GET request
- httpPost[‘param_name’]: Returns the value of parameter param_name for an HTTP POST request
- httpRequest[‘param_name’]: Returns the value of parameter param_name for an HTTP GET and POST requests
Examples #
Show only rows for a specific student.
where student_id = httpPost['student_id'] and httpPost['student_id'] is not null
Use httpGet to use a URL parameter in a query. URL example: YOURDOMAIN.com/?student_id=1
where student_id = httpPost['student_id'] and httpPost['student_id'] is not null
Add a like condition using if.
where first_name like if(
httpGet['student_firstname'] is null,
first_name,
concat( '%', httpGet['student_firstname'], '%' )
)
Show only rows for a specific student when parameter student_id is present or all rows if parameter student_id is not present.
where student_id = ifnull( httpPost['student_id'], student_id )
Notes #
- Null is returned when no argument with the given name is found
- Values are sanitized and prepared automatically
- Parameter names must be written and defined in lowercase characters.
- This feature is available to all users in the App Builder and no longer requires a premium license
Can you show / describe how to call the app with parameters?
An app can be called with parameters in two different ways:
– With shortcode parameters
– With URL parameters
Two examples that produce the same outcomes are shown below.
SHORTCODE PARAMETER EXAMPLE
shortcode: [wpda_app app_id="17" student_id="123"]
default where: where student_id = shortcodeParam[‘student_id’]
URL PARAMETERS EXAMPLE
shortcode: [wpda_app app_id="17"]
default where: where student_id = httpRequest[‘student_id’]
url: https://domain.com/?student_id=123
EXPLANATION
The shortcode parameters example always returns the student with student_id = 123 while you still have the possibility to reuse your app using a different shortcode parameter:
[wpda_app app_id="17" student_id="789"]
The URL parameters example has the benefit of providing you more flexibility. With the provided URL it returns the student with student_id = 123, but you just need to change the URL to access another student:
url: https://domain.com/?student_id=789