Skip to content

Instantly share code, notes, and snippets.

View signalpoint's full-sized avatar

Tyler Frankenstein signalpoint

View GitHub Profile
@signalpoint
signalpoint / README.md
Last active July 9, 2023 01:53
Bootstrap 4 Dynamic Modal with JavaScript

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.

@signalpoint
signalpoint / example.php
Created October 29, 2018 17:58
Drupal 7 Check if Body is Empty with EntityMetadataWrapper
<?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)) : '';
@signalpoint
signalpoint / example.php
Created May 3, 2018 02:21
Drupal 8 watchdog example
<?php
\Drupal::logger('example')->notice('Hello world');
\Drupal::logger('example')->notice('<pre>' . print_r($foo, TRUE) . '</pre>');
@signalpoint
signalpoint / example.php
Created April 30, 2018 14:01
Drupal 8 Markup Example
<?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'
]
@signalpoint
signalpoint / example.php
Last active July 16, 2022 23:41
Drupal 8 Set Message Example
<?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');
@signalpoint
signalpoint / example.php
Created January 15, 2018 15:35
Drupal 7 Push Notification Tokens for Organic Group Members
<?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");
@signalpoint
signalpoint / .gitignore
Last active January 28, 2016 17:18
angular-drupal.easystreet3.com
7
8
@signalpoint
signalpoint / .gitignore
Last active February 19, 2016 19:06
drupalgap.org
7
8
.idea
node_modules
daux.io
api
docs
demo
@signalpoint
signalpoint / .gitignore
Last active January 6, 2017 06:10
jdrupal.easystreet3.com
.idea
7
8
node_modules
@signalpoint
signalpoint / README.md
Last active January 25, 2016 21:32
AngularJS Autocomplete with Drupal 8