Skip to main content
added 3 characters in body
Source Link
Clive
  • 167.9k
  • 19
  • 303
  • 337

This one got me so many times - drupal_match_path() is expecting a newline character to separate the paths. Add this function to your project and never look back:

function _get_path_pattern_string(array $items) {
  return implode("\n"PHP_EOL, $items);
}

Example usage (overly verbose):

$patterns = array('portfolio/*', 'photo-blog', 'something-else');
$pattern_string = _get_path_pattern_string($patterns);
if (drupal_match_path($path, $pattern_string)) {
  // Do something...
}

Be sure to use double quotes to surround the \n character.

This one got me so many times - drupal_match_path() is expecting a newline character to separate the paths. Add this function to your project and never look back:

function _get_path_pattern_string(array $items) {
  return implode("\n", $items);
}

Example usage (overly verbose):

$patterns = array('portfolio/*', 'photo-blog', 'something-else');
$pattern_string = _get_path_pattern_string($patterns);
if (drupal_match_path($path, $pattern_string)) {
  // Do something...
}

Be sure to use double quotes to surround the \n character.

This one got me so many times - drupal_match_path() is expecting a newline character to separate the paths. Add this function to your project and never look back:

function _get_path_pattern_string(array $items) {
  return implode(PHP_EOL, $items);
}

Example usage (overly verbose):

$patterns = array('portfolio/*', 'photo-blog', 'something-else');
$pattern_string = _get_path_pattern_string($patterns);
if (drupal_match_path($path, $pattern_string)) {
  // Do something...
}
Source Link
Clive
  • 167.9k
  • 19
  • 303
  • 337

This one got me so many times - drupal_match_path() is expecting a newline character to separate the paths. Add this function to your project and never look back:

function _get_path_pattern_string(array $items) {
  return implode("\n", $items);
}

Example usage (overly verbose):

$patterns = array('portfolio/*', 'photo-blog', 'something-else');
$pattern_string = _get_path_pattern_string($patterns);
if (drupal_match_path($path, $pattern_string)) {
  // Do something...
}

Be sure to use double quotes to surround the \n character.