2

I've got a block view set up to get the latest 3 blog posts by term. I'm providing the default argument with the following:

$path = drupal_get_path_alias($_GET['q']);
$path = explode('/', $path);
if($path[0] == 'laws' || $path[0] == 'issues' || $path[0] == 'culprits' || $path[0] == 'themes' :
return $path[1];
endif;

Using dpm on $path[1] gives me the term alias and I assumed that the Argument validator for Taxonomy Terms, which is set to "Term Name converted to Term ID", would get me the ID, but maybe not?

Works fine in views preview with arguments entered, but on an actual page it returns nothing. Never had a problem with this before in 6.x. Is there something new I'm completely missing? I've read through docs and tried a few different ways to return the default arg, but no luck.

Any help would be appreciated.

Thanks

Edited to fix code

3
  • Apologies if I'm being overly simplistic, but you're missing $ signs on your path var in the if statement. Commented May 23, 2011 at 22:32
  • Odd - not sure how those got stripped. I added them back in. They are/were in the argument code though, so that wasn't the issue. Wish it was. Thanks for pointing that out.
    – Jared
    Commented May 23, 2011 at 23:08
  • I was trying to do something similar and your code helped me out (Previously I was using arg() to get URL arguments to the View inside of a Panel -- which, if I'm understanding why it's now working properly -- is because Panels changes arg()'s output? Still not sure.). Thanks!
    – aendra
    Commented Aug 1, 2012 at 9:00

1 Answer 1

2

Added return ''; to the argument code if the if statement was false. Somehow that did the trick.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.