Multi-Purpose Admin Area Buttons
To define multi-purpose buttons in the administrator area output, you first need to create the adminarea_buttons() function and the return of the function should be the array, the sample function is specified below.
Button Array Parameters
- text : Button name that will be displayed on the screen
- type : Specifies the type of button, the values it will have are:
transaction : When the button is clicked, assigns a request to the special function which you defined for the administrator area with javascript ajax. The value to return must be of JSON data type and the parameters (status (example: successful or error), message) must be returned. You must define the name of the function-specific to the key value of the button.
function : When the button is clicked, it refreshes the page and displays the output of the special function you defined, you need to define the name of the special function to the key value of the button.
link : When the button is clicked, it refreshes the page and redirects it to the URL address you have defined. - url : If it is a link type button, you must define the URL address to redirect.
- icon : You can use Fontawesome Icons, Ionicons icon libraries, eg: fa fa-rocket
- target_blank : Boolean data type must be defined as "true" for the buttons that refresh the page to open in a new tab when clicked.
public function adminArea_buttons()
{
$buttons = [];
$buttons['custom_transaction'] = [
'text' => 'Run Transaction',
'type' => 'transaction',
];
$buttons['custom_function'] = [
'text' => 'Open Function',
'type' => 'function',
'target_blank' => true,
];
$buttons['another-link'] = [
'text' => 'Another link',
'type' => 'link',
'url' => 'https://www.google.com',
'target_blank' => true,
];
return $buttons;
}