-
Notifications
You must be signed in to change notification settings - Fork 45
How to add user fields to any report?
Manoj L edited this page May 30, 2019
·
8 revisions
TJReport has plugins that let you index the custom fields data created using Joomla's com_fields component
Below are steps for adding user fields into an existing report.
Eg: For a plugin named mytjreportplugin
, open plugin entry file mytjreportplugin.php
Change constructor from
public function __construct($config = array())
{
$this->columns = array(
// Columns setup here
);
parent::__construct($config);
}
to below
public function __construct($config = array())
{
// Joomla fields integration - Define custom fields table, alias
$this->customFieldsTable = '#__tjreports_user_fields';
$this->customFieldsTableAlias = 'tuf';
$this->customFieldsTableExists = $this->tableExists();
$this->columns = array(
// Columns setup here
);
// Joomla fields integration - Call parent function to set custom fields columns
$this->setCustomFieldsColumns();
parent::__construct($config);
}
In step 1, we define
-
customFieldsTable
, -
customFieldsTableAlias
, - we set if
customFieldsTableExists
We also call parent method to setCustomFieldsColumns()
Change code from
public function displayFilters()
{
// Set filters code here
$dispFilters = array(
array(
// Set filters code here
),
array(
// Set filters code here
)
);
return $dispFilters;
}
to
public function displayFilters()
{
// Set filters code here
$dispFilters = array(
array(
// Set filters code here
),
array(
// Set filters code here
)
);
// Joomla fields integration - Call parent function to set filters for custom fields
$this->setCustomFieldsDisplayFilters($dispFilters);
return $dispFilters;
}