Italian (Italy)
Knowledge Base  >  Vik Restaurants  >  Hooks  >  System  >  Visualization  >  Display Management Page

apply_filters( 'vikrestaurants_display_view_{$page}', mixed $forms, JView $view )

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 vikrestaurants_display_view_managereservation. In case the page name starts with "manage", "new" or "edit", the system will trigger an additional hook without specifying that string, such as: vikrestaurants_display_view_reservation.

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:

/wp-content/plugins/vikrestaurants/admin/views/{$page}/tmpl/default.php
(back-end pages)

Parameters

$forms

(array|null)  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.

At the first hook execution, the argument may be a null value.

$page

(JView)  The page instance holding the record details.


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  $forms  An associative array of forms.
 * @param  mixed  $view   The current page instance.
 */
add_filter('vikrestaurants_display_view_reservation', function($forms, $view)
{
    if (!$forms) {
        $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', 'myplugin'));

    // add field at the end of the "Booking" fieldset, on the right side
    $forms['bookin'] = $html;

    return $forms;
}, 10, 2);

Changelog

Version Description
1.2.3 Introduced.
Ultimo aggiornamento: 2023-12-15
Utile?
Potrebbe interessarti:

Questo sito web utilizza i cookie

Questo sito web utilizza cookie e tecnologie simili. Alcune di queste tecnologie sono necessarie per il corretto funzionamento del sito web (essenziali). Altre tecnologie sono utilizzate per valutare il comportamento degli utenti (analisi), per integrare media esterni o per scopi pubblicitari. Se l'utente accetta, queste tecnologie vengono attivate. I dettagli sono riportati nella Privacy Policy. Da questa stessa pagina è inoltre possibile aggiornare/revocare il consenso. Se non si fornisce il consenso, verranno attivati solo i cookie con funzioni essenziali.

Sul nostro sito web utilizziamo tecnologie provenienti dagli Stati Uniti. Pertanto, se acconsentite, acconsentite anche al trasferimento dei vostri dati negli Stati Uniti. Desideriamo sottolineare che gli Stati Uniti non hanno un livello di protezione dei dati paragonabile a quello dell'Unione Europea e che qualsiasi azienda statunitense può essere obbligata dalle autorità statali a consegnare i vostri dati senza che voi abbiate alcuno strumento efficace di protezione legale contro questo.