Use this to dynamically create and set the content of a Bootstrap 4 Modal.
In this example, we chose an onclick handler to initialize the modal (only once), and then set the content of the modal dynamically.
| 7 | |
| 8 | |
| <?php | |
| /** | |
| * Given a group node id, this will return all the push notification tokens | |
| * belonging to users who are active members of the group. | |
| * @param $gid | |
| * @return {Array} An array of push notification strings. | |
| */ | |
| function group_member_push_notification_tokens($gid) { | |
| $query = db_select("og_membership", "ogm"); |
| <?php | |
| // The drupal_set_message() function is being deprecated! | |
| // @see https://api.drupal.org/api/drupal/core%21includes%21bootstrap.inc/function/drupal_set_message/8.5.x | |
| // > Deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. | |
| // > Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead. | |
| // In some custom code. | |
| \Drupal::messenger()->addMessage('Say something else'); |
| <?php | |
| // In Drupal 8, it seems our good friend #markup has a new friend instead: | |
| $markupElement = [ | |
| '#type' => 'inline_template', | |
| '#template' => '<p>{{msg}}</p>', | |
| '#context' => [ | |
| 'msg' => 'Hello world' | |
| ] |
| <?php | |
| \Drupal::logger('example')->notice('Hello world'); | |
| \Drupal::logger('example')->notice('<pre>' . print_r($foo, TRUE) . '</pre>'); |
| <?php | |
| // Load the node and wrap it. | |
| $node = node_load(123); | |
| $wrap = entity_metadata_wrapper('node', $node); | |
| // Make sure the body isn't empty, and then sanitize it. | |
| // We use field_get_items() because we couldn't figure out how to use EMW's __isset() on the body field. | |
| $body = field_get_items('node', $node, 'body') ? | |
| $wrap->body->value->value(array('sanitize' => TRUE)) : ''; |
Use this to dynamically create and set the content of a Bootstrap 4 Modal.
In this example, we chose an onclick handler to initialize the modal (only once), and then set the content of the modal dynamically.