Skip to content

Instantly share code, notes, and snippets.

View mortendk's full-sized avatar
🤠
git commit -m "yolo"

mortendk mortendk

🤠
git commit -m "yolo"
View GitHub Profile
@mortendk
mortendk / keybase.md
Created October 4, 2017 16:04
keybase

Keybase proof

I hereby claim:

  • I am mortendk on github.
  • I am mortendk (https://keybase.io/mortendk) on keybase.
  • I have a public key ASAnxM1of4DVXNKiDaZc3_SNXXaTT8hU0c7EilkPw4kp3wo

To claim this, I am signing this object:

[base template name]--[view machine name]--[view display id].html.twig
[base template name]--[view machine name]--[view display type].html.twig
[base template name]--[view display type].html.twig2
[base template name]--[view machine name].html.twig
[base template name].html.twig
views styles
https://www.sitepoint.com/theming-views-in-drupal-8-custom-style-plugins/
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#
@mortendk
mortendk / image-widget.html.twig
Created July 13, 2016 10:57
image widget upload label as a button trick
{#
.theme:
function birch_preprocess_image_widget(&$variables, $hook) {
// the image widget needs to know what the label is
// look in admin/image-widget.hmtl.twig
$variables['form_label_id'] = $variables['element']['#id'];
}
#}
{#
@mortendk
mortendk / input--submit.html.twig
Created July 16, 2016 11:54
input submit as buttons
{{ attach_library(active_theme()~'/form') }}
{# find the unique name for the button. #}
{% if element['#value'].getUntranslatedString() %}
{% set element_name = element['#value'].getUntranslatedString()|clean_class %}
{% else %}
{% set element_name = element['#value']|clean_class %}
{% endif %}
{# We dont use form-submit or button--primary for the css so lets remove it. #}
/**
* Implements hook_preprocess_menu().
*/
function vanilla_preprocess_menu(&$vars, $hook) {
if ($hook == 'menu_main') {
kint($hook);
$items = $vars['items'];
foreach ($items as $key => $item) {
$original_title = $vars['items'][$key]['title'];
$vars['items'][$key]['title'] = array(
@mortendk
mortendk / template-choser.md
Last active April 29, 2016 09:32
Drupal8 concept for selecting templates form the ui

template chooser

Drupal8 is pretty awesome, but its a problem that you cant choose fromt the ui which template to use. Sure you can overwrite whats there (node--article.html.twig) but that dont give the end user a chance to later change in the site & can end up in even more templates & clutter.

template suggestions

Make it easy to provide a template suggestion for entities, blocks, pages, nodes, fields, menues, username, everything that have a template you should be able to give a suggestion.

class selector

A prepopulated list of classes that can be selected for a template.

The modules userbase is sitebuilders & themes that wants to provide variations for a site, developers dont have to provide templates after a site is build, and can rely on the theme to provide all the variations.

@mortendk
mortendk / twig-loop-template.html.twig
Last active April 29, 2016 09:29
twig loop template
{# loop template #}
{% for item in items %}
{# assing foo, bar or baz to the var foo then print em out #}
{%
set var = [
cycle(["foo", "bar", "baz"], loop.index),
]
%}
{% if loop.first %}
{# first #} {{ var }}
@mortendk
mortendk / field--image.html.twig
Created September 18, 2013 15:06
field image twig
{# title wtf is this called label btw #}
{% if not label_hidden %}
<h3 {{ title_attributes }}>{{ label }}:&nbsp;</h3>
{% endif %}
{% for delta, item in items %}
{% if loop.length > 1 %} {# no wrappers if theres only 1 item#}
<section class="images" {{ content_attributes }}> {# wanna do a print all attributes but no class #}
<!doctype html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<title>mobile & drop down menu</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script>
jQuery(document).ready(function($){