Skip to content

Instantly share code, notes, and snippets.

Avatar
❤️

Sachbearbeiter sachbearbeiter

❤️
View GitHub Profile
@sachbearbeiter
sachbearbeiter / html.tpl.php
Created Feb 10, 2019 — forked from pascalduez/html.tpl.php
Drupal 7 — Move $scripts at page bottom
View html.tpl.php
<!DOCTYPE html>
<html<?php print $html_attributes; ?>>
<head>
<?php print $head; ?>
<title><?php print $head_title; ?></title>
<?php print $styles; ?>
<?php print $head_scripts; ?>
</head>
<body<?php print $body_attributes;?>>
View User has Role
<?php
// Load the currently logged in user.
global $user;
// Check if the user has the 'editor' role.
if (in_array('editor', $user->roles)) {
// do fancy stuff
}
?>
@sachbearbeiter
sachbearbeiter / theme.php
Created Apr 8, 2015
D8: Theming examples: Theme: Global theme variables - get path to the active theme
View theme.php
<?php
\Drupal::theme()->getActiveTheme()->getPath();
?>
@sachbearbeiter
sachbearbeiter / theme
Last active Aug 29, 2015
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!
View theme
<?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") {
@sachbearbeiter
sachbearbeiter / theme.php
Created Feb 2, 2015
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!
View theme.php
/**
* 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 / image.html.twig
Last active Sep 27, 2021
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!
View image.html.twig
{#
/**
* @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 / debug-renderable-array.twig
Created Jan 31, 2015
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…
View debug-renderable-array.twig
{{ dump(_context|keys) }}
@sachbearbeiter
sachbearbeiter / page.html.twig
Created Jan 30, 2015
D8: Get the current user ID in theme file and set a variable via MYTHEME_preprocess_page to use it in page.html.twig.
View page.html.twig
{# isAdmin? #}
{% if UserID == '1' %}
{{ kint() }}
{% endif %}
View gist:40968d1ffa961618947b

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:

View .bashrc
alias drush='~/drush/drush'
alias php='/usr/local/bin/php5-53STABLE-CLI'
export DRUSH_PHP=/usr/local/bin/php5-53STABLE-CLI