Make read more link in view editable.

Created on 20 September 2019, about 5 years ago
Updated 25 September 2024, 3 months ago

Is it possible to make the show more link of a view editable through a preprocess hook or template?

For WCAG 2.1 we need the read more link to be changed from

<a href="/nl/contact-en-meldpunten" class="standalone-link">Read more</a>

to something like this

<a href="#" class="read-more standalone-link" title="Teaser title text comes here.">
  <span class="visually-hidden">
    Teaser title text comes here.
  </span>
  Read more</a>

But as far as I can currently see there is no way to do this?

✨ Feature request
Status

Needs review

Version

11.0 πŸ”₯

Component

views.module

Created by

πŸ‡§πŸ‡ͺBelgium gertjanmeire

Live updates comments and jobs are added and updated live.
  • Accessibility

    It affects the ability of people with disabilities or special needs (such as blindness or color-blindness) to use Drupal.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¨πŸ‡¦Canada sebish

    This one is a bit old but since I was working on something similar, I wanted to say we can achieve this using a classic hook_preprocess_views_view.

    Example:

    function my_module_preprocess_views_view(array &$variables): void {
      $view = $variables['view'];
      if ($view->id() === 'my_view_name' && $view->current_display === 'my_view_display') {
        if (isset($variables['more'])) {
          $variables['more']['#attributes']['class'] = ['read-more', 'standalone-link'];
          $variables['more']['#attributes']['title'] = 'Teaser title text comes here.';
          ...
        }
      }
    

    Ultimately we could provide a way to easily template this with suggestion, since it's not as straightforward in my opinion.
    I'm not sure we want to leave this opened or not.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    So issue summary should be updated about why this would be needed. Recommend using standard template.

    If it moves forward will need test coverage

    All fixe should be in MR targettng 11.x

Production build 0.71.5 2024