List fetch data examples

  1. Modify div list template.

All rows data is loaded via ajax request to the rows_data.php file from the list layout folder.

The data is located in the $data array.

Through a foreach loop, each row of data is passed to the row layout view file called 'row.php', again located in the layout folder.

The data for the row is in a $row array containing the values ​​of the elements to display.

// example:
$row_data = $row;
// result:
p($row_data);

All raw values are in $row['raw_data']. To use them, you must first decode them.

// example:
$raw_data = json_decode($row['raw_data'], true);
// result:
p($raw_data);
  • Get element value from current row:
// function:
get_row_value_by_name(array $row_data, string $el_name);
// example:
$el_val = get_row_value_by_name($row, 'topics___created_by');
// result:
p($el_val);

if you have list data from multiple databases then you should use the full Бrixy element name which contains the db connection id.

// function:
get_row_value_by_name(array $row_data, string $el_name);
// example:
$el_val = get_row_value_by_name($row, 'db2__topics___created_by');
// result:
p($el_val);

To get raw element value from current row must use decoded $raw_data array.

// function:
get_row_value_by_name(array $row_data, string $el_name);
// example:
$el_val_raw = get_row_value_by_name($raw_data, 'topics___created_by');
// result:
p($el_val);

All row elements labels are located in $labels array.

  • Get element label:
// function:
get_row_value_by_name(array $row_data, string $el_name);
// example:
$created_by_label  = get_row_value_by_name($labels, 'topics___created_by');
// result:
p($created_by_label);

All brixy elements ids are located in $elements_sys_data array.

  • Get element id:
// function:
get_el_id_by_name(array $elements_sys_data, string $el_name)
// example: 
$el_id_created_by = get_el_id_by_name($elements_sys_data, 'topics___created_by');
// result:
p($el_id_created_by);

If element value have multiple results then they be delimited with ', ' by default. This occurs when the result have joined tables and Brixy list setting 'Merge Joins' is enabled.

If you want another delimiter then need to pass it to function as third parameter.

// function:
get_row_value_by_name(array $row_data, string $el_name, $delimiter);
// example:
$el_val_raw = get_row_value_by_name($raw_data, 'topics___title', '; ');
// result:
p($el_val); //return string -> 'title1; title2; title3'