1

Is there a way to filter content displayed by Views 3 using a regular expression?

I have a large list (10K items) of content of a custom type on my site and I want to create preset views for my users. The default views filter is not selective enough. I need to select with a regular expression such as /M [0-9][0-9]?[0-9]?/ in one of the fields.

Is this possible in some other way, not using a regular expression?

I'm using Drupal 7. Thanks!

1 Answer 1

1

Set up a Contextual Filter (previously know as Arguments in D6), they're hiding under the "Advanced" menu of you view. There you can put some PHP code to return a list of arguments.

Here is an example from one of my views, my PHP code return ID for a field regarding the roles of a user, it returns a string separated by "+" like 1+2+3 which is the separator for "OR" so I can select various node which have these values in this field. PHP code to provide default value

This is the configuration to provide multiple arguments. Multiple arguments configuration

1
  • Where can I get the background to understand this answer? I don't know where to plug in my RegEx or my field name. I'm not skilled enough with PHP under Drupal to make sense of this answer. Where do I go to get the info?
    – forestplay
    Aug 12, 2011 at 18:00

Your Answer

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

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