The percent sign is something I once saw in contextual filters in Drupal 6 and Drupal 7, but not Drupal 8.

What is the purpose of the percent sign in contextual filters?


3 Answers 3


The percent sign in view arguments is to tell Drupal to expect a contextual filter within the view path. It is specific to Drupal 6 and 7, linux doesn't matter.

Drupal 8 uses curly braces to accomplish this instead.

From https://www.drupal.org/node/1578576, the example provided is that user/%/comments would provide a contextual filter to show the comments for the specific user.

This resource gives screenshots and examples about how to create a contextual view filter: https://www.drupal.org/node/1578564


Here, you can see the User ID in contextual filter which we use in our view path, i.e see in the Path settings : "/user/%/profile".

This is an example for you to understand how to use % in view's path.

enter image description here


If you click on your view page path, it tells you:

enter image description here

and as you can tell from the screenshot, it is still used in Drupal 8.

If you still do not understand, basically it is a place holder. Whatever the % value is, it gets passed for your contextual filter.

Ex: view path of hello/%

When you go to yoursite.com/hello/benia, it automatically passes the word benia to your contextual filter.

Ex2: in /user/%/profile when you go to /user/10/profile it atomically passes the 10 to your contextual filter, thus only the stuff related to User ID of 10 shows up.

You could go to /user/sdlfkjlsadfklsdfja/profile and it passes sdlfkjlsadfklsdfja to your contextual filter, but since this value is no good, nothing shows up in your view page.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.