I'm writing a module and there is a text area where the users have to add paths; then, I explode these paths, and run some commands.

I would like to let users add something like "path/*" (as in context conditions).
Is it possible?

1 Answer 1


First get a list of all paths, and then check each path. Here is a quick example, and see drupal_match_path():

  // $paths would be the value of the textarea,
  //    with path expressions separated by newlines
  $paths = "mypath/*\nmy-page-name\ntopics/cheese*";
  $aliases = db_query("SELECT alias FROM {url_alias}")->fetchCol();

  $matches = array();

  foreach ($aliases as $alias) {
    if (drupal_match_path($alias, $paths)) {
      $matches[] = $alias;


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.