Skip to content

Instantly share code, notes, and snippets.

View leymannx's full-sized avatar
✍️
git reset --soft HEAD~1

Norman Kämper-Leymann leymannx

✍️
git reset --soft HEAD~1
View GitHub Profile
# disable CSS/JS aggregation
drush -y config-set system.performance css.preprocess 0 && drush -y config-set system.performance js.preprocess 0
@leymannx
leymannx / drupal_8_menu_get_object.php
Created August 19, 2016 11:38
Drupal 8 menu get object
<?php
$node = Drupal::request()->attributes->get('node');
?>
@leymannx
leymannx / ionos.sh
Last active February 17, 2024 17:33
1&1 ionos shared webhosting command line PHP Drush Composer Drupal
# https://www.ionos.com/community/hosting/php/using-php-composer-in-11-ionos-webhosting-packages/
php -v
# PHP 4.4.9 (cgi-fcgi) (built: Nov 7 2018 13:27:00)
# Copyright (c) 1997-2008 The PHP Group
# Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
/usr/bin/php7.1-cli -v
# PHP 7.1.25 (cli) (built: Dec 10 2018 10:11:36) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
@leymannx
leymannx / Drupal8HorizontalTabs.php
Last active February 16, 2024 10:10
How to create horizontal tabs programmatically in Drupal 8, requires Field Group module
<?php
// How to create horizontal tabs programmatically in Drupal 8, requires Field Group module
$form = array();
$form['my_field'] = array(
'#type' => 'horizontal_tabs',
'#tree' => TRUE,
'#prefix' => '<div id="unique-wrapper">',
'#suffix' => '</div>',
);
$items = array(
@leymannx
leymannx / fonts.css
Last active October 11, 2016 10:14
Ultimate text rendering
// https://google.github.io/material-design-icons/
body {
/* Support for all WebKit browsers. */
-webkit-font-smoothing: antialiased;
/* Support for Safari and Chrome. */
text-rendering: optimizeLegibility;
@leymannx
leymannx / theme.php
Last active October 24, 2016 11:40
Add class to paragraph
<?php
if ($paragraph->getType() == 'teaser') {
$alignment = 'left';
if ($paragraph->get('field_paragraphs_align')->first() !== NULL) {
$alignment = $paragraph->get('field_paragraphs_align')->first()->getString();
}
$variables['attributes']['class'][] = $alignment;
}
@leymannx
leymannx / SCSS.md
Created October 24, 2016 09:53 — forked from jareware/SCSS.md
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

@leymannx
leymannx / D8.md
Last active September 10, 2017 18:58

#Drupal 8 snippets

##Create absolute URL:

$options = ['absolute' => TRUE];
$url_object = Drupal\Core\Url::fromRoute('entity.node.canonical', ['node' => $nid], $options);
// will output http://example.com/path-to-my-node

##Create absolute link object (and inner span):

@leymannx
leymannx / AddAnotherItem.php
Last active July 29, 2021 10:29
Drupal 8 Ajax Form Add Item Example
<?php
/**
* @file
* Contains \Drupal\hello_world\Form\AddAnotherItem.
*/
namespace Drupal\hello_world\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
@leymannx
leymannx / mymodule.php
Created January 7, 2017 21:54
Drupal 8 user login redirect to front page
<?php
/**
* Implements hook_user_login().
*/
function MYMODULE_user_login($account) {
\Drupal::service('request_stack')->getCurrentRequest()->query->set('destination', '/');
}