Skip to content

Instantly share code, notes, and snippets.

View rosemarystanley's full-sized avatar

Rosemary Reilman rosemarystanley

View GitHub Profile
@rosemarystanley
rosemarystanley / node--database--full.twig.html
Last active September 21, 2022 15:28
Custom Node twig template
{% set database_content = node.field_database_content.0.value %}
{% set javascript_library = 'ik_maps/map-database-' ~ database_content %}
{% set map_name = node.getTitle() %}
{{ attach_library(javascript_library) }}
<div id="{{ 'map-' ~ database_content }}" class="{{ 'map-database-' ~ database_content ~'__map' }}" data-map-name="{{ map_name ~ ' Map' }}"></div>
@rosemarystanley
rosemarystanley / settings.php
Last active June 14, 2022 12:48
Constant Contact Module settings.php examples
# Example of application created with Authorization Code Flow and Implicit Flow
$settings['ik_constant_contact'] = [
'client_id' => 'yourclientid',
'client_secret' => 'yourclientsecret',
'auth_type' => 'auth_code'
];
@rosemarystanley
rosemarystanley / ModerationState.php
Created November 19, 2021 12:09
Moderation State Process Plugin
<?php
namespace Drupal\my_module\Plugin\migrate\process;
use \Drupal\Core\Database\Database;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
/**
* Custom process plugin to set a proper moderation state based on what's current on the site
@rosemarystanley
rosemarystanley / ScaldWysiwyg.php
Last active November 12, 2021 08:15
Process Plugin to capture Scald Atom embeds in Wysiwyg Fields to Media Entity Embeds
<?php
namespace Drupal\your_module\Plugin\migrate\process;
use \Drupal\Core\Database\Database;
use \Drupal\file\Entity\File;
use \Drupal\media\Entity\Media;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
use Drupal\paragraphs\Entity\Paragraph;
@rosemarystanley
rosemarystanley / ScaldAtom.php
Last active February 19, 2021 12:45
Drupal 7 Scald Atom Source Plugin for Drupal 8 Migration
<?php
namespace Drupal\your_module\Plugin\migrate\source;
use Drupal\Core\Database\Query\Condition;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
/**
* Processes Scald Media items to Drupal 8 Media entities.
*
@rosemarystanley
rosemarystanley / Game.js
Last active October 16, 2019 14:19
Load a image to a canvas
/**
* Loads the outline image and draws it on the canvas.
*/
_loadImage = () => {
const image = new Image()
const context = this.canvas.getContext('2d')
context.clearRect(0, 0, this.canvasWidth, this.canvasHeight)
image.onload = () => {
@rosemarystanley
rosemarystanley / wordpress_move
Created June 15, 2015 16:23
SQL query to move Wordpress to new URL
UPDATE `wp_options` SET `option_value` = REPLACE (`option_value`,'http://old/url', 'http://new/url') WHERE `option_value` LIKE '%http://old/url%';
UPDATE `wp_postmeta` SET `meta_value` = REPLACE (`meta_value`,'http://old/url', 'http://new/url') WHERE `meta_value` LIKE '%http://old/url%';
UPDATE `wp_posts` SET `post_content` = REPLACE (`post_content`,'http://old/url', 'http://new/url') WHERE `post_content` LIKE '%http://old/url%';
/* WP Gallery Plugin */
delimiter //
DROP PROCEDURE IF EXISTS update_wp_gallery_slides;
CREATE PROCEDURE update_wp_gallery_slides()
BEGIN
IF EXISTS (SELECT * FROM `wp_gallery_slides`) THEN