Skip to content

Instantly share code, notes, and snippets.

@chupzzz
Created June 23, 2017 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chupzzz/bcbc38201e8bb1abb87b14d66ea72e3e to your computer and use it in GitHub Desktop.
Save chupzzz/bcbc38201e8bb1abb87b14d66ea72e3e to your computer and use it in GitHub Desktop.
Match (check) given path for pattern/mask (like in Drupal blocks system).
<?php
$path = current_path();
$path_alias = drupal_lookup_path('alias', $path);
$patterns = '' . PHP_EOL . 'node/n' . PHP_EOL . 'blog/*';
if (drupal_match_path($path, $patterns) || drupal_match_path($path_alias, $patterns)) {
// Do things.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment