My Custom Pseudo Field with HTML Markup (Drupal)

Solution:

<?php

// file: my_custom_module123.module

function my_custom_module123_entity_extra_field_info() {

    $extra = [];
    // Hinweis für Bildungsurlaub
    $extra['node']['article']['display']['field_mypseudofield123'] = [
        'label' => t('My Pseudo Field 123 Label'),
        'description' => t('My Pseudo Field 123 Description'),
        'weight' => 100,
        'visible' => TRUE,
    ];
    return $extra;
}



function my_custom_module123_node_view(array &$build, EntityInterface $node, EntityViewDisplayInterface $display, $view_mode)
{


    if ($display->getComponent('field_mypseudofield123')) {
        $build['field_mypseudofield123'] = [
            '#type' => 'markup',
            '#markup' => "<div>Here comes the HTML code of <b>my custom pseudo field</b>.</div>",
        ];
    }

}

 

 

Neuen Kommentar schreiben

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

Suche

Neueste Kommentare