Editing
Template:Query/doc
Jump to navigation
Jump to search
β οΈ
Warning:
You are not logged in.
Your IP address will be publicly visible
if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username instead of your IP, along with other benefits.
Anti-spam check. Do
not
fill this in!
This template does a simple query for data from a [[Special:CargoTables|Cargo table]]. It returns data from one column of one table, by filtering one other column. This is all that is needed for many of the uses of Cargo on this wiki, but for more complex uses, you'll need to use the [[mediawikiwiki:Extension:Cargo/Querying data|Cargo functions]] directly. == Usage == Basic usage: <code>{{query|table=''table''|get=''column to output data from''|from=''name or ID''}}</code> or <code>{{query|table=''table''|get=''column to output data from''|filter_col=''column to filter''|filter_col_val=''value to filter by''}}</code> * <code>|table=</code> - The Cargo table to search in. Go to [[Special:CargoTables]] to see all tables. * <code>|get=</code> - The table column from which data should be retrieved and output. * <code>|from=</code> - If this parameter is a valid Discord ID (e.g. <code>501310750074077215</code>), then data will only be taken from table rows whose "id" column matches this parameter. If this parameter is ''not'' a valid Discord ID, then the "name" column will be searched instead. If these columns are not present in the table, or you just want to filter by a different column, then use these parameters instead: ** <code>|filter_col=</code> - The column to search. If using this parameter, you must also specify the <code>filter_col_val</code> parameter. ** <code>|filter_col_val=</code> - The value to search for in the column specified in <code>filter_col</code>. Not all parameters were listed here. For a detailed description of all parameters, see the TemplateData section below. === Examples === If you want to output the owner of [[Whenthe]], you could use either <code><nowiki>{{query|table=discord_servers|get=owner|from=Whenthe}}</nowiki></code> or <code><nowiki>{{query|table=discord_servers|get=owner|from=501310750074077215}}</nowiki></code>, which would output: {{query|table=discord_servers|get=owner|from=Whenthe}} If you wanted a list of active servers, you could do something like <code><nowiki>{{query|table=discord_servers|get=name|filter_col=status|filter_col_val=active|limit=25}}</nowiki></code>, which would output: {{query|table=discord_servers|get=name|filter_col=status|filter_col_val=active|limit=25}} == TemplateData == <templatedata> { "params": { "table": { "label": "Table", "description": "The Cargo table to search in. Go to [[Special:CargoTables]] to see all tables.", "example": "discord_servers", "type": "string", "required": true }, "get": { "label": "Field to display", "description": "The table column from which data should be retrieved and output. For example, if you wanted to find and output Whenthe's status, you would put the \"status\" column here.", "example": "status", "type": "string", "required": true }, "filter_col": { "description": "The table column that contains the values you want to filter. If using this parameter, the \"from\" parameter will be ignored, and you MUST also use the filter_col_by parameter.", "example": "name", "type": "string" }, "filter_col_val": { "description": "The value you're searching for from the column defined in the filter_col parameter. Only the data from rows that match this value in the column will be used. This parameter has no effect if filter_col is not defined.", "example": "Whenthe", "type": "string" }, "from": { "label": "From", "description": "Filters results by name or ID. If this is in the format of a Discord ID, then only results whose \"id\" column matches this parameter will be used. Otherwise, only results whose \"name\" column matches this parameter will be used. For example, if you wanted to find and output Whenthe's status, you would put Whenthe's name or ID here. If there's a different column you want to filter by, you can use the filter_col and filter_col_val parameters instead.", "example": "Whenthe", "type": "string", "suggested": true }, "limit": { "description": "The maximum number of results to get. Many queries only have one result. If there is more, and this parameter is set to a number greater than the default 1, the results will be output in a comma-delimited list.", "type": "number", "default": "1" }, "default": { "description": "What to output if no results are found.", "type": "string", "default": "(empty string)" }, "has_html": { "description": "Set this to \"yes\" if the output you want contains HTML that you want to use.", "type": "boolean" } }, "description": "Does a simple query for data from a Cargo table. It returns data from one column of one table, by filtering one other column.", "paramOrder": [ "table", "get", "from", "filter_col", "filter_col_val", "limit", "default", "has_html" ] } </templatedata> <includeonly> [[Category:Templates that query Cargo]] </includeonly>
Summary:
Please note that all contributions to Irony Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see
Irony Wiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Is Discord ID
(
edit
)
Template:Query
(
edit
)
Template:Yesno
(
edit
)
Navigation menu
Personal tools
English
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Template
Discussion
English
Views
Read
Edit source
View history
More
Purge cache
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information
Page values