Error when only entering a title for the more link and no link is specified

Created on 14 April 2025, 11 days ago

Problem/Motivation

When exposing the "More link" and only entering a text for the more link. The website returns an error.

The website encountered an unexpected error. Try again later.

InvalidArgumentException: You cannot create a URL to a display without routes. in Drupal\views\ViewExecutable->getUrl() (line 1998 of core/modules/views/src/ViewExecutable.php).
Drupal\views\Plugin\views\display\DisplayPluginBase->getMoreUrl() (Line: 2114)
Drupal\views\Plugin\views\display\DisplayPluginBase->renderMoreLink() (Line: 2238)
Drupal\views\Plugin\views\display\DisplayPluginBase->elementPreRender()

Steps to reproduce

  • Create a view with a views block override display.
  • Expose the more link.
  • Place the block in the block layout and only fill a text for the more link.
  • See the error.

Proposed resolution

See how core does it. And see if the code should be more defensive or maybe make the text field required the URL field.
Or maybe another solution...

Remaining tasks

Create MR with

  • Code changes
  • Tests to prove it works

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Active

Version

1.2

Component

Code

Created by

🇧🇪Belgium tim-diels Belgium 🇧🇪

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024