Module:Cargo/doc

From Path of Exile Wiki
Revision as of 20:12, 12 August 2018 by >OmegaK2 (→‎m_cargo.table_query)
Jump to navigation Jump to search

Functions

m_cargo.declare

This function is a simple wrapper around cargo_declare.

m_cargo.attach

This function is a simple wrapper around cargo_attach.

m_cargo.store

This function is a wrapper around cargo_store.

It will cast certain native lua to acceptable values for the store. In particular:

  • booleans -> cast to 1 or 0
  • tables -> cast to a list separated by a delimiter (default is comma)

It will also avoid calling the store function if no values are passed.

Parameters

Parameter Type Description Required Default
frame table Frame object
N/A
values assoc. table Table containing key-value pairs to store in the table.

It works exactly like cargo_store, expecting the key to be the of the field and the value the value to be stored.

The _table field must be supplied as well.

N/A
args assoc table Additional parameters for this function
N/A
args.sep assoc table Table mapping the desired delimiter/separator for fields as value to the fields in question as key.
N/A
args.store_empty boolean Allows the storing of empty rows
false
args.debug assoc table If set, log the values written by this function to console
false

m_cargo.query

m_cargo.table_query

Function parameters

Parameter Type Description Required Default
tpl_args table Parsed template arguments.

Please note those will be used/parsed by the function itself, see the template arguments section below. These will also be processed for selecting eligible display columns and passed to display functions.

N/A
frame table Frame object
N/A
main_table string The name of the main cargo table
N/A
row_unique_fields array table List of fields that identify a result as "unique". By default the page id is used.
<main_table>._pageID
empty_cell string HTML to use for empty fields
N/A by default
table_css string CSS class to add to table
N/A
data table Data table governing the display of table columns. For details see below.
N/A

Data parameters

Unless specified, each data entry is an array.

Parameter Type Description Required Default
data.tables assoc table table containing any extra conditions for tables as the "join" key.
N/A
args array table List of arguments that can be specified to display this column. The column will be shown if ANY of the parameter matches.

If left empty, the column will always be shown.

N/A
header string or

function

Table header to display.
N/A
fields array table List of fully-qualified field names for this function (table + field). Fields will be automatically queried; if the table in the field is not the main table, a join clause must be added to the tables parameter.

If a field is empty upon return, the cell will be considered empty.

Please note that this behavior can be overridden in various ways with the options parameter.

N/A
display function Display function.

The function will receive the following parameters (in this order):

  • tpl_args - tpl_args as passed to this function
  • frame - frame as passed to this function
  • tr - HTML tr object
  • rows - result rows for this cell
  • rowinfo - this object (info for the current column)
N/A
order int Number to order this display cell by. Higher numbers will be shown at the end of the table, lower numbers will be shown first.
N/A
sort_type string Sort-type to use by table-sorter plugin
number
options table array Extra options for the fields. The index used here refers to the order in which the fields were specified.
N/A

Field option parameters

Placed at data[1 ... n].options[1 ... m]

Parameter Type Description Required Default
optional boolean If set to true, the field will not count as required for the display.
false

Template parameters consumed/used

Parameter Type Description Required Default
q_<cargo_lua_parameter> string Cargo parameter passed into the query function. Please note this is not exclusive and my be altered by the function itself.

It is advised that at least q_where is specified, but not required.

q_limit will not work currently.

N/A
default string Default text to display if no results are found.
No results found.
before string Text to prepend before the table.
N/A
after string Text to append after the table.
N/A

m_cargo.parse_field_arguments

m_cargo.declare_factory

m_cargo.attach_factory

m_cargo.map_results_to_id

m_cargo.array_query

m_cargo.replace_holds

m_cargo.parse_field