Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark Conroy markconroy

View GitHub Profile
View card.twig
{%
set classes = [
"card",
card_image ? 'card--has-image',
card_style ? 'card--' ~ card_style,
card_size ? 'card--' ~ card_size,
]
%}
{% if card_link_url %}
View Choose-Image-Style-Drupal-8.twig
{% set image_file_path = content.field_teaser_image[0]['#media'].field_media_image.entity.uri.value %}
{% set image_file_alt = content.field_teaser_image[0]['#media'].field_media_image.0.alt %}
<div class="teaser__image">
{% if node.field_teaser_image_style.value == 'portrait' %}
<a href="{{ url }}">
<img src="{{ image_file_path | image_style('portrait_teaser') }}" alt="{{ image_file_alt }}">
</a>
{% endif %}
View stop-hiding-ajax-new-content-on-initial-load-2.patch
diff --git a/core/misc/ajax.js b/core/misc/ajax.js
index fefe9f3..c1c81f9 100644
--- a/core/misc/ajax.js
+++ b/core/misc/ajax.js
@@ -1061,13 +1061,19 @@
// Immediately hide the new content if we're using any effects.
if (effect.showEffect !== 'show') {
- $new_content.hide();
+ // I am commenting out the following line, as it makes any paragraph
View stop-hiding-ajax-new-content-on-initial-load.patch
diff --git a/core/misc/ajax.js b/core/misc/ajax.js
index fefe9f3..c1c81f9 100644
--- a/core/misc/ajax.js
+++ b/core/misc/ajax.js
@@ -1061,13 +1061,19 @@
// Immediately hide the new content if we're using any effects.
if (effect.showEffect !== 'show') {
- $new_content.hide();
+ // I am commenting out the following line, as it makes any paragraph
View if_not_null_sort_array_inlineentityformcomplex.php.patch
diff --git a/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php b/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php
index 0859058..7dbd166 100644
--- a/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php
+++ b/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php
@@ -574,12 +574,14 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
}
}
// Sort values by weight.
- uasort($values, '\Drupal\Component\Utility\SortArray::sortByWeightElement');
- // Let the widget massage the submitted values.
View Add bundle class to block templates in Drupal 8
{% set block_bundle = content.body['#bundle'] %}
{%
set classes = [
block_bundle ? ~ 'block--' ~ block_bundle|clean_class,
// …
]
%}
View Template suggestions for Drupal 8 custom block types
function THEMENAME_theme_suggestions_block_alter(array &$suggestions, array $variables) {
if (isset($variables['elements']['content']['#block_content'])) {
$suggestions[] = 'block__' . $variables['elements']['content']['#block_content']->bundle();
}
}
View Use Preprocess to float an image in a paragraph bundle
/**
* Implements hook_preprocess_HOOK() for paragraph--para-image-text.html.twig.
*/
function THEME_preprocess_paragraph__para_image_with_text(&$variables) {
$paragraph = $variables['paragraph'];
// Get the value of the image style and add it as a class on the image field.
$style_image = $paragraph->get('field_para_image_with_text_float')->value;
$variables['attributes']['class'][] = $style_image;
View Create Global Variable Drupal 8
function MYMODULE_template_preprocess_default_variables_alter(&$variables) {
$current_path = \Drupal::service('path.current')->getPath();
$variables['current_path'] = $current_path;
}