Adding the About Us block

After all the complex Views, Blocks, and Twig templates, adding the About Us block to our sidebar will seem quite simple. The last block to complete our Blog Listing page already exists, so adding it will just be an exercise in managing custom block layouts.

Begin by navigating to /admin/structure/block and follow these steps:

  1. Locate the Sidebar second region.
  2. Click on the Place block button.
  3. Locate the About Us block.
  4. Click on the Place block button.
  5. Select the Pages tab under Visibility.
  6. Enter the path /blog into the Page text field.
  7. On a second line, add another path to /blog/*.
  8. Make sure the Show for the listed pages checkbox is selected.
  9. Click on the Save block button.

With our About Us block assigned to the Sidebar second region, we will want to make sure it is third in the block order. Reorder the blocks if necessary and then click on the Save blocks button. We have one final piece of theming before our About Us block is complete.

Implementing the About Us template

In the case of our About Us block, we need to adjust the heading to display it similar to our Categories block. This will require us to replace the current <h2> with a <h4> heading.

Begin by navigating to the core/modules/block/templates folder and follow these remaining steps:

  1. Copy block.html.twig and place it in our theme/octo/templates folder.
  2. Rename block.html.twig to block--aboutus-2.html.twig, based on the template 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. Let's give ourselves a big pat on the back as our page is now complete:

Implementing the About Us template
..................Content has been hidden....................

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