Skip to content

Instantly share code, notes, and snippets.

View laradevitt's full-sized avatar

laradevitt laradevitt

  • Othermachines
  • Alberta, Canada
View GitHub Profile
@laradevitt
laradevitt / d8module.install
Last active June 17, 2023 14:17
(Drupal 8) Create a table in a database other than the default during module installation. Database must already be specified in settings.php.
<?php
/**
* @file
* Install, update and uninstall functions for the d8module module.
*/
function d8module_schema_otherdb() {
$schema['mytable'] = array(
'description' => 'My table description',
@laradevitt
laradevitt / d7module.install
Created September 27, 2015 19:08
(Drupal 7) Create a table in a database other than the default during module installation. Database must already be specified in settings.php. Original source: http://drupal.stackexchange.com/a/51673/28700
<?php
/**
* @file
* Install, update and uninstall functions for the d7module module.
*/
function d7module_schema_shared() {
$schema['mytable'] = array(
'description' => 'My table description.',
@laradevitt
laradevitt / openid_connect_restrict_user_register.info
Created October 13, 2015 18:18
Extends Drupal module OpenId Connect to block new account creation if registration is restricted to administrators in Account settings. Requires patch: https://www.drupal.org/node/2559543#comment-10424525
name = OpenID Connect Restrict User Register
description = Uses the OpenID Connect API to block new account creation if registration is restricted to administrators. Requires #2559543 patch.
core = 7.x
version = 7.x-1.0
@laradevitt
laradevitt / main-menu.json
Last active October 13, 2015 18:43
Example JSON output of a Drupal main menu provided by Services Menu module (services_menu).
{
"name": "main-menu",
"tree": {
"Quia Quis Tego | 506": {
"link": {
"mlid": "506",
"plid": "0",
"title": "Quia Quis Tego",
"description": "",
"path": "node/39",
@laradevitt
laradevitt / app.js
Created October 15, 2015 18:10
Render a nested Drupal menu retrieved via REST API inside an AngularJS app
// Consume a Drupal menu resource provided by Services and Services Menu modules
// and render it in an AngularJS app.
//
// A patch to Services Menu is required, see: https://www.drupal.org/node/2407135
'use strict';
var app = angular.module('app', [
'restangular',
'ngRoute',
@laradevitt
laradevitt / services_node_alias_to_system_path.info
Last active June 13, 2022 14:36
Extends Drupal Services module to handle requests on node resource containing path alias instead of node id.
name = Services Node Alias to System Path
description = Uses the Services API to convert requests containing a node path alias to a system path (e.g., 'node/5').
core = 7.x
version = 7.x-1.0
@laradevitt
laradevitt / app.js
Last active February 6, 2016 18:42
Basic Restangular-ized search front end for RESTful Search API (Drupal) - https://github.com/RESTful-Drupal/restful_search_api
'use strict';
/**
* Basic Restangular-ized search front end for RESTful Search API (Drupal)
* https://github.com/RESTful-Drupal/restful_search_api
*
* To accompany restful_search_api_example (example module).
*/
var app = angular.module('app', ['ngSanitize', 'restangular'])
@laradevitt
laradevitt / template.php
Created April 20, 2016 15:53
Remove Media module tags from body field teaser
<?php
/**
* Preprocess variables for node.tpl.php (and derivatives).
*
* Strips Media (media module) tags from teasers in article content.
* Workaround until we have a filter: https://www.drupal.org/node/2165457
*/
function MYTHEME_preprocess_node(&$variables) {
@laradevitt
laradevitt / index.html
Last active May 20, 2019 22:57
An adaptation of "Light YouTube Embeds by @labnol". Also embeds Vimeo; didn't need to build thumbnail url. Vanilla JS.
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title></title>
<link rel="stylesheet" href="styles.css">
<script src="scripts.js"></script>
@laradevitt
laradevitt / app.js
Created October 13, 2016 18:36
jPlayer + AngularJS + Prismic.io - Simple demo that uses AngularJS and prismic.io API to load an audio file into jPlayer
// Set your API endpoint below!
'use strict';
var app = angular.module('app', ['prismic.io'])
.config(['PrismicProvider', function(PrismicProvider) {
PrismicProvider.setApiEndpoint('https://[YOUR SUBDOMAIN].prismic.io/api');
PrismicProvider.setLinkResolver(function(ctx, doc) {
return 'document/' + doc.id + '/' + doc.slug + ctx.maybeRefParam;