I've had a problem for some time, cannot fix it. When using the identical argument handling code in the same view I can get a 'page view' to return results' but cannot get a 'block view' to return results. Having searched extensively through the documentation and past forum topics on Drupal.org I can find lots of posts stating to use the code I've used below, but when I use that block views do not return results while page views do.

Drupal 5, Views 1, latest stable releases of both. A vocabulary called 'tag' all fed through pathauto. URLs turn out like /tag/beach (for example, the beach tag).

A view (page and block) with the argument handling code:

<?php
 if (arg(0) == 'tag' && is_numeric(arg(1))) {
    return array(arg(1));
  }

Other code permutations, like:

if ($view->build_type == 'block' && arg(0) == 'tag' && is_numeric(arg(1))) {
  $args[0] = arg(1);
}
return $args;
?>

also fail to return results (for the case of a block view).

The result is the empty view handling text.

BUT, when going to /tag/beach/photos (the page view is setup to use /tag/$arg/photos as it's URL) I get the expected result: a page full of posts (photos in this case, the specified content type) related to the beach.

I'm curious why I can get results returned as a page view, but not as a block view? Has anyone had any experience with this, or know any work-arounds for other ways to feed an argument from the URL into a block view?

Comments

zhte’s picture

After a week of trying, I've figured it out just now.

jschulz-1’s picture

How did you fix this? I'm running into the same issue.