PHP code example of jacerider / neo_modal

1. Go to this page and download the library: Download jacerider/neo_modal library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jacerider / neo_modal example snippets


use Drupal\neo_modal\Modal;

$build['link'] = [
  '#type' => 'link',
  '#title' => $this->t('Open'),
  '#url' => Url::fromRoute('<front>'),
];

$modal = new Modal($contentRenderArray, ['title' => 'Details'], 'shelf_right');
$modal
  ->setSubtitle($this->t('More information'))
  ->setColorScheme('primary-dark')
  ->setDraggable(FALSE)
  ->setPlacementToRight();
$modal->applyTo($build['link']);

$modal = new Modal();
$modal->setTitle('Promo video')
  ->setVideo('https://www.youtube.com/watch?v=9bZkp7q19f0')
  ->setGroup('media')
  ->setTriggerOverlay($this->t('Watch Video'), 'play-circle');
$modal->applyTo($build['thumbnail']);

$form['author'] = [
  '#type' => 'neo_modal',
  '#title' => $this->t('Open Modal'),      // the trigger
  '#close' => $this->t('Cancel'),          // optional close button
  '#modal' => [
    'scope' => TRUE,
    'title' => $this->t('Modal Title'),
    'width' => '600px',
  ],
  '#modal_preset' => 'shelf_right',
  '#attributes' => ['class' => ['btn']],           // trigger attributes
  '#wrapper_attributes' => ['class' => ['mt-4']],  // outer wrapper
  '#optional' => TRUE,   // skip rendering when there are no visible children
];

$form['author']['name'] = [
  '#type' => 'textfield',
  '#title' => $this->t('Name'),
];

$form['delete'] = [
  '#type' => 'neo_modal_confirm',
  '#title' => $this->icon('Delete this thing', 'trash'),
  '#description' => $this->t('Are you sure? This cannot be undone.'),
  '#modal_title' => $this->t('Confirm'),
  '#confirm_text' => $this->t('Delete'),
  '#cancel_text' => $this->t('Cancel'),
  '#submit' => ['::deleteSubmit'],
  '#submit_element' => [],   // extra properties merged into the confirm button
  '#attributes' => ['class' => ['btn']],
];

$build = [
  '#type' => 'neo_modal_link',
  '#title' => $this->t('Edit'),
  '#url' => Url::fromRoute('entity.node.edit_form', ['node' => 1]),
  '#modal' => ['width' => '900px', 'title' => 'Edit'],
  '#modal_preset' => 'dialog',
  '#ajax_url' => $alternateUrl,   // optional: request this instead of #url
  '#ajax_method' => 'GET',        // defaults to POST
];

$build['close'] = [
  '#type' => 'neo_modal_close',
  '#title' => $this->t('Close'),
  '#check_ajax' => TRUE,   // only render inside an AJAX/dialog request
];

use Drupal\neo_modal\Ajax\NeoModalCommand;
use Drupal\neo_modal\Ajax\NeoModalCloseCommand;

$response = new AjaxResponse();
$response->addCommand(new NeoModalCommand($renderArrayOrHtml, [
  'title' => 'Hello',
  'width' => '700px',
  'fit' => TRUE,
]));

// Elsewhere:
$response->addCommand(new NeoModalCloseCommand());
bash
drush php:eval '$m = new \Drupal\neo_modal\Modal(NULL, ["title" => "T"], "shelf_right"); print json_encode($m->getValues());'
drush php:eval 'print json_encode(\Drupal::service("neo_modal.settings")->getActive()->getDiffConfigValues());'