Developer Center

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 = [];

    $status     = 'running'; /* With API, status information is obtained from the server. */

    if($status == 'running')
    {
        $buttons['restart']     = [
            'text'  => $this->lang["restart"],
            'type'  => 'transaction',
        ];

        $buttons['reboot']      = [
            'text'  => $this->lang["reboot"],
            'type'  => 'transaction',
        ];
        $buttons['stop']      = [
            'text'  => $this->lang["stop"],
            'type'  => 'transaction',
        ];
    }
    elseif($status == 'stop')
    {
        $buttons['start']      = [
            'text'  => $this->lang["start"],
            '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;
}
Adding Field to Admin Area Service Detail Defining Custom Function for Admin Area

Do you have any questions?

Feel free to contact us
Contact Us
Copyright © 2024. All Rights Reserved.
Join Our Discord Channel
Top

New Year's Special Discount

"Startup Lifetime" and "Professional Lifetime" licenses are 30% off!

Coupon Code:
HAPPYYEARS30 Copied!
Discount Rate 30%
Expiration Date December 31, 2024