1

I have a page that contains 4 separate blocks, from the same view,

Items block 1 - this contains a list of item titles Items block 2 - this contains a different list of item titles Content block 3 contains content unrelated to this functionality Results block 4 - this needs to display the details of the items that are highlighted in the above 2 sections after the user selects 'Next' in list 2.

I've found some information about passing variables to a view using contextual filters, but I'm not clear on exactly how this works still

  • how do I set up a filter - does it go in the source or target block or both?
  • how do I access the value in the target block?
  • how do the values get passed, on the URL, or as session values?

also my situation involves passing variables from 2 view blocks to another view block.

And presumably AJAX would need to be used to load the third view?

I could split the third block into 2 and display results from block one and block two separately, if that's any easier.

But I'm really not sure how to set up a filter or how to use the passed values, or how exactly contextual filters work, any guidance appreciated.

Update: I have updated this question to try to make it clearer what I have and what I need to do.

Thanks to Remy I understand how the filter value is accessible, but I still don't understand the following:

  • Is there something I have to do to enable a block to be able to receive parameters (does it need to be an attachment, an embedded view, or something else)?
0

Placing the contextual filter in the master view makes sense if every display has it, thus it still can be overridden. If there is only one block display out of X other displays, I would place the contextual filter in that display.

The contextual filter will be available as 'field' in your view and you can use it in the filter-criteria.

Contextual filters are passed via the url (in most cases), no matter if AJAX or not. Or when using views_embed_view as method-arguments.

For your propose, conditional filters nor relationships will not work.

You could then add the other view display as fields and make them conditional. But this is not really good practice nor performant. (Use also a caching module)

From views_field_view:

This view handler can accept arguments from fields of the parent view using tokens and pass them into the child view for each row. Raw or rendered token values can be used, as well as static values.

A ctools tools multi step form wizard is a better approach. here's an example https://github.com/jgottwig/ctools-wizard-example.

  • Sorry, I'm not clear on setting up the filter, do I create a contextual filter in block 1 (with the selections in)? What do I need to do in block 3, the results block, so that it uses the filter? – wot Apr 19 '16 at 18:25
  • You need to work with conditional fields, i updated the answer. Sorry for leaving this point out. – rémy Apr 19 '16 at 22:21
  • Thanks for the update, however, for the filter to be available in the results block, surely some kind of relationship has to exist between the block that is setting the value and the results block? If I add a filter this message is at the top 'This display does not have a source for contextual filters' – wot Apr 19 '16 at 23:14
  • again, updated .. a views_field_view can accept fields from the parent view. so your structure would be view_1 has view_2 as field, view_2 has view_3 as field etc then you can pass the selection (no longer contextual filters, they're not for this purpose – rémy Apr 20 '16 at 7:13
  • 'views_field_view' is a module? – wot Apr 20 '16 at 7:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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