Customize columns and data in admin’s tables

In next version of OSClass we’ll be introducing some changes on the admin side. Don’t worry, everything will look and behave the same, but it will be more flexible for plugin developers to customize the information displayed. The changes affect to items, users, alerts, comments, media and page tables, and will allow plugin developers to add and remove columns. For example, the cars attributes plugin will show the make and model on the listings’ table, making it easier to manage your listings.


Example code to modify the columns:

function columns_items_table_header($table) {
/* $table is a pointer to the table and not a copy, so the original DataTable is being used
* $table->addColumn("my_identifier", __("Name of the colum", "columns"), $priority);
* $priority is an integer from 1 to 10, being 1 the first (left) and 10 the last (right)

$table->addColumn("my_own_first_column", __("My First Column", "columns"), 1);
$table->addColumn("my_own_last_column", __("My Last Column", "columns"), 10);
$table->addColumn("my_own_column", __("My Own Column", "columns"));

function columns_items_row($row, $aRow) {
/* $row is the current row of the table (formatted)
* $aRow is the raw data of the row (in this case, an item)
* $row['column_identifier'] = "Cell text";
$row['my_own_first_column'] = "First (pk_i_id: ".$aRow['pk_i_id'].")";
$row['my_own_last_column'] = "Last (s_secret: ".$aRow['s_secret'].")";
$row['my_own_column'] = "Data (fk_i_category_id: ".$aRow['fk_i_category_id'].")";
return $row;

As you could see, it’s very easy and intuitive.

Download the complete example plugin