3

using display suite's block field, which i chose a view block.. so when i have view page ('parent' view) it list many nodes. each node has a field for block view ('child' view).

how do i get child view to filter its results by the node id it is being displayed with in parent view? like a contextual filter, but not getting nid from url, but the node the block field is part of.

i like using display suite layouts, but need to rewrite the author field link. so i figure id make view to show the author and rewrite, then insert it into the node view mode as field. but i cant filter the child field how id like.

0

Use the Views Field View Module, which allows you to insert other views as fields.

  • Add a field of Content: nid. In settings, hide from display.
  • Add field of Global: View (child view). In settings, click on Available tokens and put the nid token as your filter.
1
  • ill give it a shot but i know ive done it in past without additional modules.
    – brandonc
    Nov 7 '15 at 23:27
4

You should use Display Suite Dynamic Field instead of Block Field.

It allows you to select a view and pass the appropriate contextual filter arguments.

From Dynamic Field documentation:

A dynamic field can be used in combination with the Views Content Pane submodule of Ctools to pass contextual arguments to a view. Steps:

  • Install Ctools, Views, and Display Suite.
  • Enable the Views Content Panes module and Views UI.
  • Create a new view. Add a contextual filter--for example, node NID. Add a content pane display. Configure the "arguments" argument of the display to enable the exposed filter you added. For example, select "From context" as the source of the argument and "Content ID" as the context.
  • Create a dynamic field.
  • Under manage display for a given content type, configure the dynamic field to use the views content pane you configured.
0

I just hit this use case in 2020 with Drupal 8. Here's the recipe I used with Display Suite and Views.

Create your DS Block Field using what will be the "child view." A critical setting is the configuration of that field. Set the content to "Node from URL." The default of "None" works fine for a regular node display, but not in a child View.

I also made a custom Display Mode for the content type using DS's 1-col layout and displaying only that block field. This isn't necessary strictly, but is useful if your parent View is field based, as I tend to make them. DS fields aren't true fields, and so aren't recognized by Views. However, there is an option to display a rendered entity as a field in field-based View. I chose that option and set the display mode to use my custom set up with the single field to get around that issue.

My parent View, as noted is field-based. I bring in the desired fields for the main rows with one of those fields being the rendered entity using my display mode. Works like a charm! I have no doubt you could do this with a Content or DS-Content based View, but I haven't experimented with it. I just prefer field based Views.

And if anyone's about to say, "But you can just use Views' grouping functionality," yes that's true, but the markup produced by that out of the box is not very nice when you want several fields "grouped" per row and a simple sublist.

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.