This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_field_group_build_pre_render_alter(). | |
* See https://git.drupalcode.org/project/field_group/-/blob/4.x/field_group.api.php | |
*/ | |
function MYMODULE_field_group_build_pre_render_alter(&$element) { | |
// Only act on node view displays | |
if (empty($element['#node']) || !($element['#node'] instanceof NodeInterface)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Changes the language switcher block to use country codes instead of long format country names | |
// So if the site was in English/Italian, the original switcher would show (at D9 iirc): | |
// English - Italian, and this code makes it into EN - IT (lack of correct formatting notwithstanding) | |
// This could easily be adapted to show flags etc instead I imagine. | |
/** | |
* Implements hook_preprocess_block(). | |
*/ | |
function mytheme_preprocess_block(&$variables) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function customtheme_preprocess_html(&$variables) { | |
$variables['#attached']['html_head'][] = [ | |
[ | |
'#type' => 'html_tag', | |
'#tag' => 'style', | |
'#value' => 'custom-class { background: red; }' | |
], | |
'my-custom-theme' | |
]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.view-VIEWNAME td .dropbutton-multiple { | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
padding: 0 !important; | |
margin: 0 !important; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Provides suggestions for different parts, so that blocks are properly loaded | |
* | |
* @see hook_theme_suggestions_alter() | |
* | |
* @param array $suggestions | |
* @param array $variables | |
* @param string $hook | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "paragraph.html.twig" %} | |
{% block paragraph %} | |
<div{{ attributes.addClass('panel-group') }} id="accordion-{{ paragraph.id() }}" role="tablist"> | |
{% for field in content %} | |
{% set field_instance_items = [] %} | |
{% for key, field_instance in field if key|first != '#' %} | |
{% set field_instance_items = field_instance_items|merge([field_instance]) %} | |
{% endfor %} | |
{% if field_instance_items is not empty %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements hook_theme_suggestions_HOOK_alter(). | |
* Courtesy @nicrodgers | |
*/ | |
function MYTHEME_theme_suggestions_block_alter(array &$suggestions, array $variables) { | |
if (isset($variables['elements']['content']['#block_content'])) { | |
$block_content = $variables['elements']['content']['#block_content']; | |
$suggestions[] = 'block__' . $block_content->bundle(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// paragraph text field actual text | |
{{ paragraph.field_title.value }} | |
// paragraph link field uri - internal:/ style (useless?) | |
{{ paragraph.field_link.0.uri }} | |
// content has this value - is processed, not validated (good in some cases) | |
{{ content.field_link[0]['#url'] }} | |
// paragraph image field uri |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div{{ attributes.addClass('container') }}> | |
{% for item in items %} | |
{# NB! notation: loop.index is 1 start, loop.index0 is zero start #} | |
<div class="row {{ loop.index0 is odd ? 'zebra-odd' : 'zebra-even' }}"> | |
<div{{ item.attributes }}>{{ item.content }}</div> | |
</div> | |
{% endfor %} | |
</div> |
NewerOlder