Make your data sources flexible with system and user defined params
Starting with version 4.1 the data sources parameters can contain user variables that get their value in one of the following ways:
- Joomla editor
- HTTP Request (GET/POST)
- Logged in User/System environment
For example, in this case we are using a data source that getting its data from the following database query:
SELECT `id`,`title` FROM `#__content` WHERE catid = 2 LIMIT {user_param_1:int}
The user_param_1 will have a default value that you specified when we added the data source into the article, but this value can be overwritten in the URL.
You can try that yourself, by adding to the URL of this page the parameter data_source_user_params=1%3A7 that will set the user_param_1 = 7. You can also click here to reload the current page with this URL argument and see how the number of rows will increase to 7.
Current page URL with user param value set:
http://www.tabulizer.com/index.php/support-menu/tabulizer-tips/62-data-source-params?data_source_user_params=1%3A7
Below is the sample output for this example:
For security purposes you can specify the data type of the user params and if they can overwritten by URL parameters. Please read the documentation for more details on that.
- {user_id}
- {user_name}
- {user_email}
- {user_fullname}
- {user_lastvisit_date}
- {user_register_date}
- {user_groupids}
- {site_lang}
- {current_datetime}
- {user_param_ID_url:DATA_TYPE}
- {user_param_ID_editor:DATA_TYPE}
- {user_param_ID:DATA_TYPE}
ID is an integer value (i.e. 1,2,3, ….)
DATA_TYPE can be:
- int: integer
- float: float, real, decimal
- date: date
- cmd: can contain latin letters (a-z), numbers (0-9), the underscore (_), the period (.) and the hyphen (-).
Here are some examples:
{user_param_1_url:int}, {user_param_2_editor:cmd}, {user_param_10:float} When trying to assigning a value to these user defined variables, the following rules apply:
- {user_param_ID_url:DATA_TYPE} can take the value only from the GET/POST request
- {user_param_ID_editor:DATA_TYPE} can take the value only from the editor.
- {user_param_ID:DATA_TYPE} will take the value from the editor, and it will be overwritten by the GET/POST value, is present. In other words: if {user_param_ID_url:DATA_TYPE} is specified {user_param_ID:DATA_TYPE} = {user_param_ID_url:DATA_TYPE} else {user_param_ID:DATA_TYPE} = {user_param_ID_editor:DATA_TYPE}