Last active
August 29, 2015 14:08
-
-
Save amcgowanca/ee3f1d89fd06e51697c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Returns the node identifier should the path be a node viewing path. | |
* | |
* Note: This function returns FALSE for all node action or local task paths | |
* such as node/[nid]/edit. | |
* | |
* Furthermore, a node alias may be specified as $path which will perform a path | |
* normalization allowing for the node system path to be retrieved and parsed. | |
* | |
* @param string $path | |
* The path to attempt to retrieve the node id for. | |
* | |
* @return mixed | |
* Returns the node id as an integer, otherwise FALSE. | |
*/ | |
function MY_MODULE_path_is_node_view($path) { | |
$path = drupal_get_normal_path($path); | |
if (preg_match('|node/([0-9]+)?|', $path, $matches)) { | |
return isset($matches[1]) && is_numeric($matches[1]) ? intval($matches[1]) : FALSE; | |
} | |
return FALSE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For a complex usage and multiple variations, see http://github.com/amcgowanca/drupal_uuid_menu_links.