layout_builder_theme_suggestions_test.module

Same filename and directory in other branches
  1. 8.9.x core/modules/layout_builder/tests/modules/layout_builder_theme_suggestions_test/layout_builder_theme_suggestions_test.module
  2. 10 core/modules/layout_builder/tests/modules/layout_builder_theme_suggestions_test/layout_builder_theme_suggestions_test.module
  3. 11.x core/modules/layout_builder/tests/modules/layout_builder_theme_suggestions_test/layout_builder_theme_suggestions_test.module

For testing theme suggestions.

File

core/modules/layout_builder/tests/modules/layout_builder_theme_suggestions_test/layout_builder_theme_suggestions_test.module

View source
<?php


/**
 * @file
 * For testing theme suggestions.
 */

/**
 * Implements hook_theme().
 */
function layout_builder_theme_suggestions_test_theme() {
    // It is necessary to explicitly register the template via hook_theme()
    // because it is added via a module, not a theme.
    return [
        'field__node__body__bundle_with_section_field__default' => [
            'base hook' => 'field',
        ],
    ];
}

/**
 * Implements hook_preprocess_HOOK() for the list of layouts.
 */
function layout_builder_theme_suggestions_test_preprocess_item_list__layouts(&$variables) {
    foreach (array_keys($variables['items']) as $layout_id) {
        if (isset($variables['items'][$layout_id]['value']['#title']['icon'])) {
            $variables['items'][$layout_id]['value']['#title']['icon'] = [
                '#markup' => __FUNCTION__,
            ];
        }
    }
}

Functions

Title Deprecated Summary
layout_builder_theme_suggestions_test_preprocess_item_list__layouts Implements hook_preprocess_HOOK() for the list of layouts.
layout_builder_theme_suggestions_test_theme Implements hook_theme().

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.