I need to check if a url exists in a module that I am creating. How should I go about doing this? I tried to use a @get_headers() function with php, but sadly that doesn't work. I am wondering if there is a built in drupal function that I can use?
-
api.drupal.org/api/drupal/includes!path.inc/function/… drupal_valid_path– notabotsureCommented Aug 17, 2015 at 16:12
-
I am using that function, but sadly it never returns false.– MattCommented Aug 17, 2015 at 16:20
-
There is a comment: Unlike many other Drupal "path" functions, drupal_valid_path() considers absolute/external urls to be valid "paths". Did it help you?– notabotsureCommented Aug 17, 2015 at 16:34
-
You can also look here api.drupal.org/api/drupal/includes%21path.inc– notabotsureCommented Aug 17, 2015 at 16:37
Add a comment
|
1 Answer
This is what fixed it:
if (!drupal_valid_path($path)) {
// Not a system URL.
if (!drupal_lookup_path('source', $path)) {
// Not a path alias.
// $path does not exist.
}
}
Where $path
is a relative url.