I have created a RESTful view in Drupal 8, there I need to display a few of node contents by node alias in contextual filter.

View URL: www.example.com/api/book-details/{node-alias}

Instead of node alias if I use node ID, it's working fine. For example: api/book-details/100 (node ID 100) is working fine.

URL alias for node 100 is "first-content". So how do I fetch details using node alias in contextual filter? For example: api/book-details/first-content (this is not giving any result).


As No Sssweat already mentioned in his comment there is no Contextual filter available for path aliases, you can try to create your own (and share on drupal.org while you're at it :) ).

But if you have set your aliases based on node Titles then you may get away with using Content: Title as your contextual filter.

Just be careful about the Case in Path setting and you'll probably need Transform spaces to dashes in URL under More.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.