Display Table Head
public function onDisplay{$page}TableTH(JView $view, array $config) : array
Fires while displaying the table head of a specific entity.
Description
This hook is triggered within the list pages of certain sections of the plugin. It is possible to use this hook to include additional columns with list tables.
DO NOT include a th
tag because it is automatically added by the system. Lean on data-id
attribute for individual styling.
The dynamic portion of the hook name, $page
, refers to the name of the page calling the hook. This means that, for example, the services page will trigger an hook called onDisplayServicesTableTH
.
IMPORTANT NOTE: not all the pages trigger this hook. Before to start coding a plugin, you should make sure that the page supports that hook, by checking whether the onDisplayTableColumns()
method is used. This can be done by accessing the page at the path:
/administrator/components/com_vikappointments/views/{$page}/tmpl/default.php
(back-end pages)
Parameters
- $page
-
(JView) The page instance holding the record details.
- $config
-
(array) An associative array of options.
Return Value
Array. An associative array containing the new columns to include. The key of the array should be a unique identifier to correctly pair the head with the body. The value of the array should be the legend to display.
Example
The example below displays the difficulty column within the services table.
It is assumed that the database table of the services already declares a column to hold the difficulty level, such as difficulty.
/**
* Trigger hook to allow the plugins to include custom <TH> within the table.
* The hook must return an associative array where the key is the identifier
* of the column and the value is the HTML to use.
*
* @param mixed $view The current page instance.
* @param array $config A configuration array.
*
* @return array An associative array of columns.
*/
public function onDisplayServicesTableTH($view, $config)
{
$head = array();
// include "Difficulty" column
$head['difficulty'] = 'Difficulty';
return $head;
}
Changelog
Version | Description |
---|---|
1.7 | Introduced. |