Posted by hundreds on December 11, 2008 at 7:31pm
Is there a function for returning the parts of an aliased path? I'm looking for something equivalent to the arg() function.
I've been using something like this:
<?php
$path_parts = explode('/', drupal_get_path_alias($_GET['q']));
?>but this would return an empty array if there were just a single part, ie. http://localhost/about
Comments
_
afaik, it should still work.... try this to see:
print_r(explode('/','about'));You should get:
Array ( [0] => about )Edit: I made my own alias version (aarg) of the drupal api arg function:
<?phpfunction aarg($index = NULL, $path = NULL) {
if (!isset($path)) {
$path = drupal_get_path_alias($_GET['q']);
}
if (!isset($arguments[$path])) {
$arguments[$path] = explode('/', $path);
}
if (!isset($index)) {
return $arguments[$path];
}
if (isset($arguments[$path][$index])) {
return $arguments[$path][$index];
}
}
?>
===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.
you're right, that does
you're right, that does work. Anyways this function was what I was really going for, thanks!
welcome ;-) === "Give a man
welcome ;-)
===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.
static
WorldFallz: Just curious why you didn't include the
static $arguments;from the arg function
_
Probably just an oversight, though I confess, in this function I'm not sure what its purpose would be.
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.
subscribe
subscribe