Skip to content

Instantly share code, notes, and snippets.

@bogomolov-dev
bogomolov-dev / field--field-paragraph-gallery-photos.html.twig
Created August 9, 2016 05:53
Bildstil (image style) im Template überschreiben - Drupal 8
@bogomolov-dev
bogomolov-dev / 01_ausgangslage.php
Last active August 5, 2016 06:41
Array anhand eines Array mit den Keys zuschneiden
<?php
$haystack = [
'k1' => 'value 1',
'k2' => 'value 2',
'k3' => 'value 3',
'k4' => 'value 4',
'k5' => 'value 5',
];
@bogomolov-dev
bogomolov-dev / get-active-theme-name.php
Last active August 2, 2016 13:29
Namen des aktiven Theme in Drupal 8 auslesen
<?php
// Name des aktiven Themes
\Drupal::theme()->getActiveTheme()->getName();
main {
max-width: 600px;
margin-left: auto;
margin-right: auto;
}
.full-width {
width: 100vw;
position: relative;
left: 50%;
@bogomolov-dev
bogomolov-dev / .htaccess
Created October 22, 2015 06:06
xmlrpc-Schnittstelle deaktivieren
<Files xmlrpc.php>
Order Deny,Allow
Deny from all
</Files>
@bogomolov-dev
bogomolov-dev / .htaccess
Created October 22, 2015 06:04
wp-login über .htaccess absichern
AuthUserFile /var/www/... ../wp-admin/.htpasswd
AuthName "Members Only"
AuthType Basic
<Files "wp-login.php">
require valid-user
</Files>
@bogomolov-dev
bogomolov-dev / mymodule.php
Created August 31, 2015 12:19
Cache in Drupal 8 für einzelne Inhaltstypen oder Seiten deaktivieren
<?php
function mymodule_preprocess_html(&$variables) {
if (array_key_exists('node_type', $variables) && $variables['node_type'] === 'category') {
\Drupal::service('page_cache_kill_switch')->trigger();
}
}
var copyBtn = document.querySelector('#copy');
copyBtn.addEventListener('click', function (event) {
event.preventDefault();
try {
document.querySelector('#code').select();
document.execCommand('copy');
}
catch (error) {
alert('Sorry, leider konnte nicht kopiert werden.');
@bogomolov-dev
bogomolov-dev / source-00.php
Last active August 29, 2015 14:19
Kommagetrennte Liste in ein Array umwandeln und jeden Wert validieren
<?php
function getFormatedArray($string) {
$result = array();
if (strpos($string, ',') !== false) {
$substrings = explode(',', $string);
foreach ($substrings as $substring) {
if (trim($substring) != '') {
@bogomolov-dev
bogomolov-dev / my_theme.theme
Last active August 29, 2015 14:14
"Generator" Angabe im Meta-Tag entfernen - Drupal 8
<?php
function my_theme_preprocess_page(array &$variables)
{
/** @var \Drupal\Core\Page\HtmlPage $page */
$page = $variables['page']['#page'];
$metaElements = $page->getMetaElements();
foreach ($metaElements as $index => $metaElement)
{