Expose URL alias fields to views

Created on 22 May 2023, about 1 year ago
Updated 3 April 2024, 2 months ago

Problem/Motivation

URL alias data is not available in views.

Steps to reproduce

1. Create a new view at admin/structure/views/add
2. 'URL alias' or 'URL alias revisions' don't appear as options in View settings > Show dropdown.

Proposed resolution

Add a new class that extends Drupal\views\EntityViewsData and add as a handler to Drupal\path_alias\Entity\PathAlias. The handler will expose the id, revision_id, uuid, landcode, path, alias and status fields in the path_alias table.

Remaining tasks

Write a patch
Tests
Review
Commit

User interface changes

URL alias and URL alias revisions will appear as options in View settings > Show dropdown.

API changes

None.

Data model changes

None.

Release notes snippet

TBD

Feature request
Status

Needs work

Version

11.0 🔥

Component
Path 

Last updated 6 days ago

  • Maintained by
  • 🇬🇧United Kingdom @catch
Created by

🇦🇺Australia mcaddz

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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.

  • Issue created by @mcaddz
  • Assigned to isalmanhaider
  • Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    Not currently mergeable.
  • @isalmanhaider opened merge request.
  • 🇵🇰Pakistan isalmanhaider

    @mcaddz can you confirm if the pathauto module is enabled or not?

  • 🇦🇺Australia mcaddz

    @isalmanhaider no this just relates to the core path_alias module.

  • 🇦🇺Australia queenvictoria

    Hi there @mcaddz and @isalmanhaider. I've just figured out how to add some of these features to path_alias myself but would like to test/extend/progress your work instead. If I look at the git repo I can't see how to create a patch for your work against D9.5. It looks like you probably were working against 10.1. Is there a way to create a patch that I can bring in to my composer.json?

  • 🇦🇺Australia mcaddz

    @queenvictoria it doesn't look like there's any commits in MR 4026 yet.

    You might need to rebase your changes against core 9.5.x and upload a patch file here to add to composer.patches.json.

  • 🇦🇺Australia queenvictoria

    Thanks @mcaddz.

    Attached is my patch against 9.5.

    Should I go ahead and make an MR as well?

  • 🇦🇺Australia mcaddz

    @queenvictoria yes absolutely :)

    You could either push to 4026 or create a new 11.x issue fork. Will need tests though.

  • last update 8 months ago
    Custom Commands Failed
  • Status changed to Needs review 8 months ago
  • 11:11
    9:52
    Running
  • 🇮🇳India _utsavsharma

    Fixed failures in #9.

  • Status changed to Needs work 8 months ago
  • 🇸🇰Slovakia poker10

    Thanks for working on this. I think this still needs tests (as per IS and #10).

  • 🇦🇺Australia acbramley

    Something worth pointing out here that our client just found is that the Url ViewsField plugin doesn't handle alias/paths properly when display_as_link is set.

    This is because it always prepends a / to the path. In the case of path_alias entities, they already have a /. This results in double slashes and breaks the url entirely. We should ensure we have test coverage around this and probably just add an ltrim to the plugin.

Production build 0.69.0 2024