I'm cross posting as I originally had this in the module dev forum but wasn't getting any bites. I've installed CCK and views and everything works great. I wanted to try viewfield, but none of my nodes are displaying anything.

I created a debug view that spits out a small table of node titles (limited to 4) and uses the argument handler to put debug info into the footer. I found that viewfield isn't properly handling the view at all. For instance, when I go to the URL of the debug view on its own, I get the small table followed by my arguments.

When I go to the URL of the node that has the viewfield, instead of following my view's rule of a small table, it wants to show the whole table of node titles (not limited to 4), and also the debug footer shows that the argument passing into it isn't being delimited properly.

What's supposed to happen is that the argument in the viewfield is comma separated, but all of my arguments are being passed in one character at a time. Meaning that instead of "test" as a single argument (which it successfully parses in its own dedicated view URL), in my viewfield node it gets passed into the view as four arguments t, e, s, and t.

This also happens with the built-in arguments of viewfield. If I enter an argument of %author, my debug code shows that the args passed in were %, a, u, t, h, o, and r.

As a sanity check, I entered an argument of *test. This ended up showing something since I have * as a wildcard in my view. But the debug code is still showing that while * was an appropriate value for $args[0], the rest of the letters are being passed each as their own argument.

I started playing around and started entering commas, and likewise those got treated as a character. I started getting suspicious when I went into the viewfield hook for argument handling and forced the arguments to return as 'foo' and 'bar', but was still getting the same individual letters as arguments. It seems that some other function is stepping on the hook and not allowing me to properly run, because the explode PHP call isn't being run at all. Any ideas where this rogue hook function might be hiding?


derjochenmeyer’s picture

I have the same problem. And im also working on a solution, but up to now i have no clue...


rdollete’s picture

It isn't a solution, but I've circumvented the problem by solving it in a different way.

I wanted to use the views to effectively have a node for saved queries. Instead, I'm exposing the filter and then passing the filter result as an argument in the argument handling code. It's ugly, and I can't get multiple filter entries to work, but it works for single filter requests.

My argument code begins with:

$vf = views_filters_form($view);
$dv = print_r($vf['filter0']['#default_value'], TRUE);

Which then allows me to get the filter form results as a string variable. I pass that on to my SQL query (pre- and post-pended with an apostrophe) to give me my set of results.

* I get access to the exposed filter widget, meaning I only need to have one entry point for the queries
* I still can't elegantly display multiple views for a single argument, which is what I really wanted. In other words, I'm still not using viewfield in any way, shape or form.

rdollete’s picture

I edited the viewfield_field_formatter() function in the module:

    // $args = $item['vargs'];
    $args[] = $item['vargs'];

This seemed to fix the single character parsing problem. However, there is still no comma-delimiting, nor is there %author substitution. However, the rest of it works well enough, as my views only take a single argument anyway.

A quick sanity check for anyone is to also make sure that the "display fields" tab in content types has the Full view set to Entire view.

JohnG’s picture

Apologies if this is off-topic but I'm struggling to understand all this. I think my problem may be related. If so, I would welcome any (event the most basic) pointers or explanations:

  • I'm using a NodeRef (type=stories) as an exposed filter on a calendar view (calendar module).
  • I assumed that the filter passes the selection of NIDs as a sub-array within a single arg(?) but now I'm beginning to wonder :(
  • The URL caused by the exposed filter looks like this: (I've spaced it to make it more legible)

    .../drupal5/calendar? filter0%5B%5D = 21 &filter0%5B%5D = 23 &filter0%5B%5D = 3 &filter0%5B%5D = 24 &filter0%5B%5D = 29 &filter0%5B%5D = 25

  • It seems to be passing 6 separate arguments and obliterating the calendar arguments altogether ... the calendar reverts to current month (default) whenever the filter is resubmitted. :(
  • I think part of the problem is Calendar's argument system, but the other part is the exposed filter hogging too much argument space ? Should it be doing that?
  • and if the sequence of args (eg arg(0), arg(1), arg(2)) is an unpredictable number how on earth can I get Handling code to catch it all and work with it ?

I'm perplexed
any suggestions most welcome.