Get path
sami_k - March 4, 2006 - 04:24
| Project: | Node Image Block |
| Version: | HEAD |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | budda |
| Status: | closed |
Jump to:
Description
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...
<?php
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;
}
?>
#1
Thanks - have added your function to CVS / 4.7.0.
#2
since you committed it, i am going to close this.. thanks!
#3
This 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.#4
#5
thanks for the clarification.
#6
i have checked, and this is in fact the case! so do revert the code back as tenrapid suggests... sorry about that.
#7
Reverted back to original code.
#8