Skip to content

Instantly share code, notes, and snippets.

@shadcn
shadcn / local.services.yml
Created December 14, 2016 08:24
Example local.services.yml
# Local development services.
#
# To activate this feature, follow the instructions at the top of the
# 'example.settings.local.php' file, which sits next to this file.
services:
cache.backend.null:
class: Drupal\Core\Cache\NullBackendFactory
parameters:
twig.config:
debug: true
@shadcn
shadcn / settings.local.php
Created December 14, 2016 08:23
Example settings.local.php
<?php
/**
* @file
* Local development override configuration feature.
*
* To activate this feature, copy and rename it such that its path plus
* filename is 'sites/default/settings.local.php'. Then, go to the bottom of
* 'sites/default/settings.php' and uncomment the commented lines that mention
* 'settings.local.php'.
@shadcn
shadcn / ActionsNoDropButton.php
Last active August 8, 2017 09:01
Add an actions_no_dropbutton Element to render form actions without the dropbutton
<?php
namespace Drupal\et_article\Element;
use Drupal\Core\Render\Element\Actions;
/**
* Provides a wrapper element to render buttons for a form.
*
* Usage example:
* @code
@shadcn
shadcn / gist:4c79632956564f1d2ef321ad6aa83941
Created May 11, 2016 08:36
Drupal Element::children in Twig templates
{% for key, child in element if key|first != '#' %}
<div>{{ child }}</div>
{% endfor %}
@shadcn
shadcn / gist:cde26afc528a7bc7ae8d68ce658a8f2d
Created April 21, 2016 20:22
field_info_instance or how to get field info in Drupal 8
<?php
use Drupal\field\Entity\FieldConfig;
$info = FieldConfig::loadByName($entity_type, $bundle, $field_name);
@shadcn
shadcn / assign_permission.php
Last active April 20, 2016 18:28
Progammatically assign permissions to users in Drupal 8
<?php
use Drupal\user\RoleInterface;
// Allow anonymous and authenticated users to access contact form.
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access site-wide contact form'));
user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('access site-wide contact form'));
@shadcn
shadcn / create_menu_link.php
Last active September 10, 2018 09:33
Programmatically create a menu link in Drupal 8
<?php
/**
* Implements hook_forms().
*/
function node_ajax_loader_forms($form_id, $args) {
$forms = array();
if (strncmp($form_id, 'node_ajax_loader_form_', 22) === 0) {
$forms[$form_id] = array('callback' => 'node_ajax_loader_form');
}
@shadcn
shadcn / gist:5ea3aa3a4ce4cd345aa8
Created December 9, 2015 06:33
Drupal + Bootstrap + Sass + Gulp + Browsersync + FontAwesome
Download and enable radix: drush en radix -y; drush vset theme_default radix
Create a subtheme: drush cc all; drush radix "Subtheme"
Set default theme: drush en subtheme -y; drush vset theme_default subtheme
Install required modules: cd /path/to/subtheme; npm run setup
Update browserSyncProxy in /path/to/subtheme/config.json
Watch: gulp
@shadcn
shadcn / gist:3f78074de48ae295b341
Created December 1, 2014 14:50
Cocoapods stuck on “analyzing dependencies”

Run the following:

$ pod repo remove master
$ pod setup
$ pod install