Good module! I would suggest that you the following function to get the nid because the method you're using would be problematic if the node is aliased. I would suggest that you just have it as a local function. I think something similar needs to be in the core...
function getnid(){
$path = drupal_lookup_path('source', $_GET['q']);
if($path == false){
$path = $_GET['q'];
}
$pathvars = explode('/', $path);
if ($pathvars[0] == 'node'){
$nid = $pathvars[1];
}
return $nid;
}
Comments
Comment #1
buddaThanks - have added your function to CVS / 4.7.0.
Comment #2
sami_k commentedsince you committed it, i am going to close this.. thanks!
Comment #3
tenrapid commentedThis is unnecessary.
During bootstrap $_GET['q'] gets set to the system path and does not contain an aliased path anymore.
So the good old
if(arg(0) == 'node') { $nid = arg(1); ...is the way to go.Comment #4
tenrapid commentedComment #5
sami_k commentedthanks for the clarification.
Comment #6
sami_k commentedi have checked, and this is in fact the case! so do revert the code back as tenrapid suggests... sorry about that.
Comment #7
buddaReverted back to original code.
Comment #8
(not verified) commented