Theming a Block template

In the case of our Categories block, we can begin by navigating to the core/modules/block/templates folder and following these remaining steps:

  1. Copy block.html.twig and place it into our theme/octo/templates folder.
  2. Rename block.html.twig to block--views-block--categories-block-1.html.twig based on the template's suggestions.
  3. Next, we will need to replace the current markup with the following new markup to convert the default <h2> to <h4>:

    New markup

    {% set classes = ['block'] %}
    
    <div{{ attributes.addClass(classes) }}>
      {{ title_prefix }}
    
      {% if label %}
        <h4{{ title_attributes }}>{{ label }}</h4>
      {% endif %}
    
      {{ title_suffix }}
    
      {% block content %}
        {{ content }}
      {% endblock %}
    
    </div>

Once finished, make sure to save the template, clear Drupal's cache, and then refresh the Blog listing page in the browser. Our Categories block heading is now displayed properly. We have managed to alter the heading of our Categories block, but we still need to modify the output of our categories to display as an unordered list, along with any additional CSS classes we may need. Time to add a Views template.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.85.135