Hey guys,
Im asking this here cuz you guys are the most knowledgeable drupalers i know! (and im getting no love on #drupal-support) And also, I found Ryan Price's article on DrupalEasy relating to this but not quite the same... http://drupaleasy.com/blogs/ryanprice/2008/06/using-views-2-drupal-6-create-related-pages-block
Ill im trying to do is grab the last part of a url that has been created using pathauto, (ie. /content/arg-value) and pass it to a block view. I know that i have to provide a default argument using php but the sample snippet i found here (and tweaked for my situation ....
$path = drupal_get_path_alias($_GET[‘q’]); //get URL alias $path = explode(‘/’, $path); //break path into an array if ($path[0] == ‘content’ && $path[1] != ”) { return $path[1]; }doesnt seem to work. Is content considered an argument? Is there an easier way to grab the argument? Any help would be much appreciated.

Comments
If the drupal functions
If the drupal functions aren't working, you could just use php..
$url = $_SERVER['QUERY_STRING'];
and then pull out the needed parts
Thanks for the input
Thanks for the input cbosner.
it appears that it was just a copy paste error. an extra space caused the issue.
The copy & paste friendly version is as follows::
$path = drupal_get_path_alias($_GET['q']); //get alias of URL$path = explode('/', $path); //break path into an array
//user print_r($path); to see what the $path array looks like
if ($path[0] == 'content' && $path[1] != '') {
return $path[1];
}
"spooky action at a distance"
What about using the arg() function?
Can you use the arg() function?
http://api.lullabot.com/arg
IE: return arg(2); //Where 2 is the third object in the path
www.rightsprocket.com
www.rightsprocket.com
It's generally not a good
It's generally not a good idea to test against the URL Alias, which is what @rightspricket was getting at. Aliases can change, but arguments will not. It's more sound to base your logic on arg().
Normally, one would check the drupal arguments, like node/305/edit would be : arg(0) == "node", arg(1) == "305", arg(2) == "edit", and so on...
What content are you trying to get at?
Ryan Price
DrupalEasy
Ryan Price
DrupalEasy Podcast
I was trying to pass the
I was trying to pass the name of an artist to a block so that the block would show all art pieces by that artist. As seen here:: http://www.skinnybuddha.com/content/swamburger
It works as long as the content creator spells the name of the artist correctly... I know that's not foolproof, but the content creators are me and one other person so it works for now..
"spooky action at a distance"
Yeah, but content/swamburger
Yeah, but content/swamburger is actually an alias to node/37 or whatever... the argument you should be looking for is not the title, but the node ID. The node ID will never fail.
I guess I would need to see your code. Aren't you coming to the Community Helpdesk?
Ryan Price
DrupalEasy
Ryan Price
DrupalEasy Podcast