Keep working on the BeansTag module. One suggestion is to validate if the path exists when submitting a new BeansTag.
We can use drupal_valid_path() to check if a Drupal system URL exists.
if (drupal_valid_path('node/1')) { // url exists } else { // url does not exists }
According to the specification, this function allows dynamic URL checking like
if (drupal_valid_path('user/*', TRUE)) { // url exists } else { // url does not exists }
But the above code DOES NOT work at all. For more information, please refer to the following thread.
drupal_valid_path fails for dynamic paths (e.g. user/% cannot be added to menus)
Another thing you need to pay attention is that this function returns FALSE for path alias. So if you want to validate a URL for both system URL as well as path alias. You may need the following piece of code.
if (!drupal_valid_path($path)) { // Not a system URL. if (!drupal_lookup_path('source', $path)) { // Not a path alias. // $path does not exits } }
Done =)
Reference:
The wildcard would be a ‘%’, not a ‘*’!
LikeLike
These two functions does not work in case of translated nodes
LikeLike