Display Management Page
public function onDisplayView{$page}( JView $view ) : array
Fires while displaying the management page of a record.
Description
This hook is triggered within the management pages of certain sections of the plugin. It is possible to use this hook to include additional pieces of code within specific positions of the related page, such as to support new parameters.
The dynamic portion of the hook name, $page
, refers to the name of the page calling the hook. This means that, for example, the managereservation page will trigger an hook called onDisplayViewManagereservation
. In case the page name starts with "manage", "new" or "edit", the system will trigger an additional hook without specifying that string, such as: onDisplayViewReservation.
In addition to the mentioned arguments, some hooks might report other arguments that may result helpful to the developers.
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 onDisplayView()
or onDisplayManageView()
methods are used. This can be done by accessing the page at the path:
/administrator/components/com_vikrestaurants/views/{$page}/tmpl/default.php
(back-end pages)
Parameters
- $page
-
(JView) The page instance holding the record details.
Return Value
Array. An associative array containing the HTML to include. By adding the HTML within a reserved key of the page, the plugin will display the entered string within the position assigned to that key. In case of an unknown key, the HTML will be appended within specific custom form fields/tabs.
Example
The example below displays a custom field within the management page of a restaurant reservation.
/**
* Trigger filter to allow the plugins to include custom HTML within the page.
*
* @param mixed $view The current page instance.
*
* @return array An associative array of forms.
*/
public function onDisplayViewReservation($view)
{
$forms = [];
// load previoulsy selected value or take the default one
$custom_value = $view->reservation->custom_value ?? '';
// create HTML of the field
$html = $view->formFactory->createField()
->type('text')
->name('custom_value')
->value($custom_value)
->label('Custom Setting');
// add field at the end of the "Booking" fieldset, on the right side
$forms['bookin'] = $html;
return $forms;
}
Changelog
Version | Description |
---|---|
1.8.3 | Introduced. |