0

The percent sign is something I once saw in Drupal 6 and Drupal 7, but not Drupal 8. It has been a few years ago; I don't recall where exactly inside a view, but most probably inside the contextual filter criteria.

What is percent sign in the arguments?

2
  • Can you please update your question with information about what version of Drupal you are running, along with a little about the dev environment; also a screen shot of the view or some context about where you are seeing this? Thanks! – Christia Dec 23 '16 at 4:03
  • Your question is unclear. Can you provide an example of what your exactly asking about? Are you asking about using a % in the views page URL? What version of Drupal? – nvahalik Dec 23 '16 at 4:04
5

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

0
1

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

0
0

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.

0

Your Answer

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