0

I have a block showing a unformated List of fields. Now I would like to use twig to style that block.

I am able to use block--views-block--blockname-block.html.twig to do the outer styling. But I could not get the fields out of the content.

0

Not sure to understand what you mean...

Do you want to customize the fields that appear in your block?? If so, Drupal normally provides you with available twig hooks you could use. Yours would probably be field.html.twig.

Exemple : you can customize a menu with menu.html.twig and then customize the links in that menu with links.html.twig

  • Thanks. Actually I try to override the views-view-unformatted.html.twig template with a specific only showing up on one node but it seems like it won't work. – Finn Oct 1 '15 at 9:23
0

Ok I got it. I've already overwritten form templates to add a template suggestion that included the form id. Here's the code :

function hugo_theme_suggestions_form_alter(array &$suggestions, array $variables) {
    if (isset($variables['element']) && isset($variables['element']['#type']) && $variables['element']['#type'] == 'form') {
        $original_theme_hook = $variables['theme_hook_original'];
        $suggestions[] = $original_theme_hook . '__' . str_replace('-', '_', $variables['element']['#id']);
    }
}

Maybe you could reuse this piece of code changing the form by the view, something like YOURTHEME_theme_suggestions_view_alter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.