Skip to content

Instantly share code, notes, and snippets.

Avatar

Tyler Frankenstein signalpoint

View GitHub Profile
@signalpoint
signalpoint / README.md
Last active Jul 10, 2019
Bootstrap 4 Dynamic Modal with JavaScript
View README.md

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 Oct 29, 2018
Drupal 7 Check if Body is Empty with EntityMetadataWrapper
View example.php
<?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
Drupal 8 watchdog example
View example.php
<?php
\Drupal::logger('example')->notice('Hello world');
\Drupal::logger('example')->notice('<pre>' . print_r($foo, TRUE) . '</pre>');
@signalpoint
signalpoint / example.php
Created Apr 30, 2018
Drupal 8 Markup Example
View example.php
<?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 Jul 9, 2020
Drupal 8 Set Message Example
View example.php
<?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 Jan 15, 2018
Drupal 7 Push Notification Tokens for Organic Group Members
View example.php
<?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 Jan 28, 2016
angular-drupal.easystreet3.com
@signalpoint
signalpoint / .gitignore
Last active Feb 19, 2016
drupalgap.org
View .gitignore
7
8
.idea
node_modules
daux.io
api
docs
demo
@signalpoint
signalpoint / .gitignore
Last active Jan 6, 2017
jdrupal.easystreet3.com
View .gitignore
.idea
7
8
node_modules
@signalpoint
signalpoint / README.md
Last active Jan 25, 2016
AngularJS Autocomplete with Drupal 8
View README.md
You can’t perform that action at this time.