I see how I can pass an argument from a parent view (where I'm using the viewfield), using the token.

However in my child (fielded, attached, whatever) view, I can't set the contextual filter and get it to work.

I've tried setting the default argument to !1, and some other ridiculous-seeiming things too, but, could I please just have help, telling me how to get the argument to work in the attached view? Thanks!

Comments

beanluc’s picture

Title: Argument corrupted in passing to child view » Argument corrupted in passing to child (attached) view

I'm changing this to bug. Two other people have the same issue http://drupal.org/node/1409292#comment-5496396

What was done:
Created View listing nodes with (1) a certain boolean value and any term from a certain vocabulary. This view represents the "landing pages" for some collections of articles.

Created View listing nodes without (0) that boolean value, and with a specific term from that vocabulary. This view represents the "child pages" of those collections of articles.

Added Global:View field to the "landing pages" view, so that each row listing a landing page would also show a view listing the child pages with the matching taxonomy term as well. Set this view field to pass the term as argument. The term was listed among available tokens.

Added contextual filter to the child view, validating incoming argument against taxonomy terms in the specified vocabulary.

The argument was passed in text format as well as tid format, and the validation was also tried in both configurations.

Added to the Header of the child view, a dpm() to see the exact value of the incoming argument.

Expected behavior:
Child views should get the taxonomy term (or term ID) as incoming argument.

Actual behavior:
dpm() reveals that the Child view gets nid as incoming argument.

So, child view always yields the behavior specified for invalid argument.

beanluc’s picture

Title: Set default argument in child (attached) view? » Argument corrupted in passing to child (attached) view
Component: Documentation » Code
Category: support » bug
StatusFileSize
new12.41 KB
new11.57 KB

Exports of parent and child views attached here. TID version

beanluc’s picture

Termname version this time: Exports of parent and child views attached here.

beanluc’s picture

Title: Argument corrupted in passing to child (attached) view » Argument corrupted in passing to child view

Two other people have the same issue http://drupal.org/node/1409292

And the reason I'm not on that issue is that I'm not using multiple arguments - in fact, unlike the first person in the other issue, nid is not even an argument at all in my scenario.

damiankloip’s picture

Title: Argument corrupted in passing to child (attached) view » Argument corrupted in passing to child view

Ok, I will take a look at this today and see what is going on. This looks like a dupe issue to me though :) You said above that you were passing in both tid and term? Even so, It's the same problem/bug I think.

You have provided alot of info (which is good), so hopefully I can work out what is going on!

damiankloip’s picture

in #2 how are you getting you tid? is the token available to pass into the view field '[tid]' ? Are you using the field field_behind_the_scenes with is just a plain text version of the formatted term, So NOT the term ID but the output from the field display formatter.

I have tried this on my local machine and it works fine passing in a tax term BUT I created a relationship for 'Content: Taxonomy terms on node' then used that relationship to display the tax term ID.

Give that a try?

damiankloip’s picture

Category: bug » support
beanluc’s picture

You said above that you were passing in both tid and term?

Not as two simultaneous arguments, but, I tried it both ways.

how are you getting you tid? is the token available

It was, at one point. I double-checked and I see that in the version attached above in #2 that token isn't, so, I recognize that was a bad test.

I re-created the previous case where I did have a TID token. Ordering that field so that it's not first, makes the tid token available. So, I've done it this way instead of by creating a Relationship.

This version of the scenario is attached here.

This time the result is a little different: This time, the argument is completely absent coming into the child view (as usual, confirmed with dpm() ), so, the child view produces the "filter value not available" behavior, which in this case is "display all results".

beanluc’s picture

Category: bug report » support request

To the extent that this is known/expected behavior on your part, I'll agree that requesting documentation/help is a support request on my part.

But I have to ask, in what way is the passing of NID, or, no argument at all, *not* a corruption of the argument which is both available and specified? Even if there's a known work-around, I'm having a hard time perceiving this as not a bug.

Anyway thanks for your help!

beanluc’s picture

Trying something else:

field_behind_the_scenes has the -tid available as a rewrite output token, so, I'm rewriting that field's regular term output as the -tid. Then using the regular field token as the argument value to send to the child display (not the -tid token, which is actually not available as an argument after all).

Same as ever, getting the NID as the received argument. New versions exports attached.

FYI, I also tried it your way, with a Relationship. Tried it on both parent and child, singly and simultaneously. This yielded absolutely no change at all.

Thanks again!

damiankloip’s picture

Where are you doing the dpm? This might not reflect the eventual args/output of the view.

I'm confused, because I set up a view to show content that had the same term as the current term. Used a relationship then put this relationship in the fields as taxonomy term id. You then _definitely_ get the term tid. Just adding the relationship will not do anything, and you will not gain anything from having a relationship on the child view. Did you add it in the fields too.

Also, have you checked the order of the fields? So, all of the fields you want to use tokens from are arranged before the view field?

beanluc’s picture

Thanks, let me make sure to add the relationship as a field. I overlooked that part.

Where I'm doing dpm(): That's in the header of the child view. You could see the actual code I'm using to load the view object and dpm() the args in any of the exports. I will say: the child-view behavior certainly does reflect what args appear (via that means of inspecting) to be sent. When arg is absent, the child view gives the "absent arg" behavior. When NID is sent, the child view gives the "validation failed" behavior.

Thanks again, I'll try the relationship again and report back.

beanluc’s picture

You could see the actual code I'm using to load the view object and dpm() the args in any of the exports.

Well, don't let me send you on a code-hunt. It's as follows:

$handler->display->display_options['header']['area']['content'] = '<?php
$view = views_get_current_view();
dpm($view->args);
?>';
$handler->display->display_options['header']['area']['format'] = 'php_code';
That's in the header of the child view.
beanluc’s picture

OK, the relationship thing works. I'm getting the behavior I need now.

Thanks very, very much.

One more thing along the lines of "support request": Can you assist with my education, and help me to understand why NID would *ever* be passed as an arg value, when a specific token is both available and specified? I won't question the case where no arg at all gets sent - clearly that's what one might expect, when one didn't configure an arg properly.

beanluc’s picture

This really is becoming a problem. When I stated just above that I was now getting the required behavior, it turns out that only in Preview was that happening. Adding the field from the taxonomy relationship made the actual block break (yield no results).

So Preview gave me the right behavior but I can't use it in real life. I don't know why that is, it's certainly got nothing at all to do with Views Field View, but it's a barrier - an unnecessary one, since I can't even imagine why a taxonomy relationship would be required at all. When including the Content: All taxonomy terms field, [term_node_tid] becomes available as a token... when I try passing that, I get NID in the viewfield view instead.

I can't imagine why arguments would not get passed, or, sometimes an argument gets passed and it is the NID rather than whatever value I *really* tried to pass.

Arguments are just not reliably passed to viewfield views. I, and others, have seen this happen with a whole bunch of different configurations. I can't even put hardcode values in the Arguments-to-pass field and see them arrive into the child View. Sometimes nothing is passed, sometimes the useless NID is passed.

What am I missing? Just what, exactly, is necessary, to get a value passed as an argument to the viewfield view? Why is this so unreliable and obscure?

damiankloip’s picture

There is currently an issue with using values from fields I'm sure (especially if you are trying to aggregate the query). If you are adding this relationship for tax terms on the current node, you should create a field for taxonomy term tid not any other one. When the field issue is fixed this hopefully wont be a problem. There are a few difficult things to consider when fixing it though I'm afraid!

beanluc’s picture

OK, I understand. Thank you for confirming that it isn't simply my own ignorance at work, here. Although, if it had been a matter of ignorance on my part, then, that would not have been unwelcome either.

So: Are you able to recommend a work-around for me? If people are generally *not* using values from fields as their arguments into the viewfield view, then, what exactly *are* they doing?

Or, knowing what you do about how arg-passing is done, is there any wizardry you can think of to make a work-around even while the "real" feature isn't working? Perhaps an alternative implementation idea which does not depend on views-field-view at all?

Thanks a lot!

Aha, last thing: Could you link me to the issue where the matter you described is open? I'm interested to read the details. TYVM again.

beanluc’s picture

There is currently an issue with using values from fields

Well, OK. That is primarily what I have been trying to achieve in my particular use-case.

However, "I've tried setting the default argument to !1, and some other ridiculous-seeiming things" including "put[ting] hardcode values in the Arguments-to-pass field " and that that doesn't work either. Frankly, these don't seem that ridiculous, and even while you've confirmed that using args from field-values might currently be troublesome, could you educate me about why nothing else I've tried yields a successful arg-passing either? ***

I remain convinced that there's something which you and all the other users of this module have managed to divine somehow (according to http://drupal.org/node/1171604, dereine's language there is quite convincing indeed) and which I'm just not understanding (notwithstanding filthypixel's and MBroberg's clear instructions).

For the moment, I'm busy creating a real README file largely based on MBroberg's post #3 in the above-linked issue. It's clearly going to be a useful and welcome contribution, though I confess feeling a little insincere about doing it (even in the sincere spirit of helpfulness and participation) since those instructions don't work for *me*. I guess I'll just offer a patch the 6.x branch with that, not the 7.x branch, as a means of mitigating that conflicted feeling.

*** except in the extremely special, and not-workable, case where I use the relationship. See #15 above, the arg passing works but the overall solution does not (through no apparent fault of views_field_view)

markhalliwell’s picture

StatusFileSize
new1.08 KB

Actually it seems to be a bug with the token processing. Attaching a patch.

damiankloip’s picture

This patch looks like it is just using the token string if the field alias isn't found, as the argument....Looking at it now, not sure how that will help? Unless I am missing something here.

markhalliwell’s picture

Sorry if I hijacked this issue. I thought at the time it was related. I'll just post a new issue.

damiankloip’s picture

Status: Active » Fixed

This issue should be fixed after the latest wave of commits. The args shouldn't be using the 'nid' alias now.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.