Skip to content

Instantly share code, notes, and snippets.

View sachbearbeiter's full-sized avatar
❤️

Sachbearbeiter sachbearbeiter

❤️
View GitHub Profile
@sachbearbeiter
sachbearbeiter / country-list-german.html
Last active June 7, 2023 20:29
German country SELECT element in HTML
<select name="country">
<option value="DE" selected>Deutschland</option>
<option value="AT">Österreich</option>
<option value="CH">Schweiz</option>
<optgroup label="A">
<option value="AF">Afghanistan</option>
<option value="EG">Ägypten</option>
<option value="AX">Åland</option>
<option value="AL">Albanien</option>
<option value="DZ">Algerien</option>
@sachbearbeiter
sachbearbeiter / comment.tpl.php
Created April 3, 2014 15:02
D7: Comments: Get access via foo_preprocess_comment(&$variables) to the comment authors profile image from an ($user) imagefield and print it into the comment.tpl.php template.
<? if (!empty($image)) : ?>
<img src="<?= image_style_url('mini',$image); ?>" alt="Profile image" />
<?php endif; ?>
<?php
/* Script located in the docroot for your Drupal 8 site */
use Drupal\Core\DrupalKernel;
use Drupal\Core\Site\Settings;
use Symfony\Component\HttpFoundation\Request;
$autoloader = require_once __DIR__ . '/core/vendor/autoload.php';
use GuzzleHttp\Client;
@sachbearbeiter
sachbearbeiter / .bashrc
Last active August 29, 2015 14:14 — forked from cbeier/.bashrc
alias drush='~/drush/drush'
alias php='/usr/local/bin/php5-53STABLE-CLI'
export DRUSH_PHP=/usr/local/bin/php5-53STABLE-CLI

Install Composer on Managed Hosting at Domainfactory

Step 1:

Log in to your Managed Hosting Server via SSH

Step 2:

Add these two lines to .bashrc:

@sachbearbeiter
sachbearbeiter / page.html.twig
Created January 30, 2015 10:18
D8: Get the current user ID in theme file and set a variable via MYTHEME_preprocess_page to use it in page.html.twig.
{# isAdmin? #}
{% if UserID == '1' %}
{{ kint() }}
{% endif %}
@sachbearbeiter
sachbearbeiter / debug-renderable-array.twig
Created January 31, 2015 15:42
I'm not sure if I'm being too obvious but 'item' is a placeholder some "renderable array". Depending on which template you are in that variable name will change. Within any template you can get a list of the available variables when you have twig_debug turned on by means of {{ dump(_context|keys) }} which if I remember right kint() will be nicer…
{{ dump(_context|keys) }}
@sachbearbeiter
sachbearbeiter / image.html.twig
Last active September 27, 2021 09:05
D8: Theming examples: Images: How to print individual image values and suppress width and height via the image.html.twig template ... *First results of struggling through Drupal 8 - better solutions are probably out there! **Drupal 8 is still Beta - improvements through API modifications are possible!
{#
/**
* @file
* Default theme implementation of an image.
*
* Available variables:
* - attributes: HTML attributes for the img tag.
* - style_name: (optional) The name of the image style applied.
*
* @see template_preprocess_image()
@sachbearbeiter
sachbearbeiter / theme.php
Created February 2, 2015 08:42
D8: Theming examples: Theme: New more specific suggestions for the image.html.twig template ... *http://drupal.stackexchange.com/questions/137652/override-image-formatter-html-twig/141340#141340 **Drupal 8 is still Beta - improvements through API modifications are possible!
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function MYTHEME_theme_suggestions_image_formatter_alter(array &$suggestions, array $variables) {
$entity = $variables['item']->getEntity();
$field_name = $variables['item']->getParent()->getName();
$suggestions[] = 'image_formatter__' . $entity->getEntityTypeId() . '__' . $entity->bundle() . '__' . $field_name;
}
@sachbearbeiter
sachbearbeiter / theme
Last active August 29, 2015 14:14
D8: Theming examples: Theme: Additional suggestion for content block templates: taking the bundle type into account. *First results of struggling through Drupal 8 - better solutions are probably out there! **Drupal 8 is still Beta - improvements through API modifications are possible!
<?php
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function MYTHEME_theme_suggestions_block_alter(array &$suggestions, array $variables)
{
$block = $variables['elements'];
$blockType = $block['#configuration']['provider'];
if ($blockType == "block_content") {