Fieldable Path

Component ID

2873081

Component name

Fieldable Path

Component type

module

Maintenance status

Development status

Component security advisory coverage

covered

Downloads

4556

Component created

Component changed

Component body

The module contains a field type which provides 1:1 reflection of "path" property (defined in entities to determine their human-readable URL alias).

Why would I need "path" property as a field?

Some headless Drupal successors (like JSON API) do not provide a way to filter entities by "path" property due to technical limitations (See #2799909: [BUGFIX] Return the alias and allow filtering on it).

It means that if you'd want to implement a dynamic routing from your frontend application (something more human-readable than just /article/[id]) then your app has to know which entity to render when an end user hits /article/[path] page. So far the only way to achieve this is to filter entities by path stored as a field.

Usage

  1. Install the module as usual
  2. Add "Fieldable Path" field to your entity through "Manage fields" page
  3. Create or update any entity

Now you can do the following (assuming you've added the field to "article" node with name "field_path"):

GET http://{host}/jsonapi/node/article?filter[field_path][value]=/my-article

Note that Pathauto is supported, so you can get all power of Drupal to generate human-readable aliases for your frontend application.

What to do if your site already has some content?

The module includes an action which clones path property to the field in a bulk mode. To find it, go to the node / user list page, select necessary items and pick "Copy path to Fieldable Path field" in the action selection dropdown.