By rhodes_muc on
Hello,
In Drupal 9 installation there is a view where nodes are listed. Now I want to do two things.
1: add a field with the path alias to the view.
2: add an exposed filter to filter path aliases.
Unfortunately I am not able to do this. The only way to add a field with path alias is the field "Link to Content", which can be output as plain text. But I cannot define an exposed filter for this field.
Another thought was to use hook_views_data() to create a relationship between the tables Node and Path_alias. The problem is that path_alias does not have a field with the entity_id, but with 'node/3'...
I am grateful for any tip, rhodes
Comments
What is the real use case and
What is the real use case and what kind of operators do you need to support in the contextual filter?
Alternatively, you can consider to use the DataTables module. In case you only need the "Is equal to" operator you can implement it with the Views URL Alias Filter module. Add the "Content: ID" contextual filter, select the "Provide default value" option and choose the "URL alias to entity ID" from the "Type" listbox. After that you can create a block with the form like this:
You can also create a similar form using the Webform module as shown in the following video: How to create a custom Views exposed filter form.
I created the exposed filter
I created the exposed filter that enables to filter nodes by URL aliases. You may try the Views alias filter module.