Skip to content

Instantly share code, notes, and snippets.

Avatar

Danny Englander danny-englander

View GitHub Profile
@froboy
froboy / nucular-option.sh
Last active Jul 21, 2020
Sometimes composer (in your Drupal 8 environment) gets grupmy... when that happens, it's time to go nucular.
View nucular-option.sh
######
# This script intentionally deletes a lot of things that could be important!!!!!
# Please be sure you have a backup before you go nucular!!!!!
#####
# Depending on where your web root is...
rm -rf vendor/ && rm -rf web/core && rm -rf web/modules/contrib/ && rm -rf composer.lock
# or
rm -rf vendor/ && rm -rf docroot/core && rm -rf docroot/modules/contrib/ && rm -rf composer.lock
@NikLP
NikLP / zebra.html.twig
Last active Feb 25, 2021
Set zebra-style (odd/even) classes in twig loop in drupal 8 (bootstrap) theme
View zebra.html.twig
<div{{ attributes.addClass('container') }}>
{% for item in items %}
{# NB! notation: loop.index is 1 start, loop.index0 is zero start #}
<div class="row {{ loop.index0 is odd ? 'zebra-odd' : 'zebra-even' }}">
<div{{ item.attributes }}>{{ item.content }}</div>
</div>
{% endfor %}
</div>
@konstantin-morenko
konstantin-morenko / list-categories-count.liquid
Last active Jan 21, 2021 — forked from Phlow/list-categories-count.liquid
Jekyll: List all categories with according post count and show and link all post items listed in the according category
View list-categories-count.liquid
<h2>Categories</h2>
<ul>
{% assign categories_list = site.categories %}
{% if categories_list.first[0] == null %}
{% for category in categories_list %}
<li><a href="#{{ category }}">{{ category | capitalize }} ({{ site.tags[category].size }})</a></li>
{% endfor %}
{% else %}
{% for category in categories_list %}
<li><a href="#{{ tag[0] }}">{{ category[0] | capitalize }} ({{ category[1].size }})</a></li>
View _utility.border.scss
/*
Borders
- - - - - - - - - - - - - - - - - - - - - - - - -
Helper classes for adding borders to elements
Class names follow this convention:
.[type][direction][size]
@lewisnyman
lewisnyman / field.html.twig
Last active Dec 21, 2016
minimal field.html.twig — Drupal 8
View field.html.twig
{% for item in items %}
{{ item.content }}
{% endfor %}
@jacurtis
jacurtis / _spacing-helpers.scss
Last active Apr 26, 2021
SASS Margin and Padding Helpers Loop. Generates .m-t-10 type helper classes.
View _spacing-helpers.scss
/*
This .scss loop will create "margin helpers" and "padding helpers" for use in your web projects.
It will generate several classes such as:
.m-r-10 which gives margin-right 10 pixels.
.m-r-15 gives MARGIN to the RIGHT 15 pixels.
.m-t-15 gives MARGIN to the TOP 15 pixels and so on.
.p-b-5 gives PADDING to the BOTTOM of 5 pixels
.p-l-40 gives PADDING to the LEFT of 40 pixels
@nadavoid
nadavoid / composer-pantheon.md
Last active Nov 7, 2016
Using composer to manage a single site build on Pantheon
View composer-pantheon.md

This doc has been moved to my blog: https://www.davidlanier.com/blog/2016/11/using-composer-on-pantheon

I worked through https://pantheon.io/blog/using-composer-relocated-document-root-pantheon and chased a few rabbits, and ultimately landed on what I think a pretty simple workflow. The main thing I was interested in was how to use composer to effectively manage a drupal project on pantheon. Composer is practically required for building the codebase of Drupal 8 because there are so many external dependencies now. Composer handles downloading the right versions of all packages.

The main steps:

  • Create a new site at pantheon, selecting "Drops 8 Composer"
@jacine
jacine / icon.html.twig
Last active Nov 2, 2016
Icons for Menu Item links broke with 8.2 upgrade!
View icon.html.twig
{#
/**
* @file
* Drupal pass-through template for icon theme hook implementation.
*
* @see /themes/THEME/components/icon.twig.
*/
#}
{% embed '@components/icon.twig' %}{% endembed %}
@waako
waako / themename.theme.php
Last active Oct 6, 2016
Drupal 8 Block and Menu template suggestions
View themename.theme.php
<?php
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function THEMENAME_theme_suggestions_block_alter(array &$suggestions, array $variables) {
$block_id = $variables['elements']['#id'];
// See if block ID contains the word mobile.
$is_mobile_block = strpos($block_id, 'mobile');
$block = \Drupal\block\Entity\Block::load($block_id);
@thejimbirch
thejimbirch / paragraph--default.html.twig
Last active Mar 22, 2021
Drupal 8 Template for Bootstrap Paragraphs customized for Width and Background color fields.
View paragraph--default.html.twig
{#
/**
* @file
* Default theme implementation to display a paragraph in Bootstrap Paragraphs.
*
* Available variables:
* - paragraph: Full paragraph entity.
* - id: The paragraph ID.
* - bundle: The type of the paragraph, for example, "image" or "text".
* - authorid: The user ID of the paragraph author.