0

I'm trying to this done :

I have two entities

1) Listing Details 2) Listing Premium Settings. This entity references the first Listing Details entity.

In the second Entity I have referenced entity 1 Listing Details, added with fields for a StartDate and a EndDate.

I would like a view on Entity 1 where I will use the StartDatet and EndDate of Entity 2 as a filter.

I have tried contextual, I have tried Relationships, but I guess I do not graps the essences of both ... :-(

Anyone who can help me get this done ?

I use Drupal 8.7. I am a newbie.

Alex

2 Answers 2

0

A view of entity one in relation with entity 2 referenced field may work, but maybe you can try the other way around:

  • Create a view of Entity 2 (Listing Premium Settings) with field titles or nid that you exclude from display (and maybe remove at the end)
  • Create your filters at your convenience of time
  • Define your relationship: content referencing the first entity
  • Then add the fields of entity one you wish to display in your view, using the relationship in these fields.

In that sense it might give you more control on the filters which are attached to entity 2.
In the other sense (entity 1 relationship to entity 2) it gives you more control on the fields of entity 1 to display in case of multi-value field for example.

0

Your Listing Premium Settings is the "child" and the Listing Details is the "parent" through the ER (entity reference) relationship.

You want to create a list of "child" node information on the "parent" nodes. You do that with the help of a Contextual filter for the ER field that connects the two types.

List "ER Child" info on "ER Parent" nodes

  1. Create Views with Block display listing the "child" nodes (in your case it's Listing Premium Settings)
  2. Add the Contextual filter for the ER field and configure it (do not use any Relationships if you have them added in Views): When the filter value is NOT available
    Provide default value
    Content ID from URL
    When the filter value IS available or a default is provided
    Specify validation criteria
    Content
    Listing Details

    Adjust other options to your needs/preferences.

  3. Optional: If you need to show some "parent" information in this Views you will need to add the Relationship for the ER field, and then use that Relationship when adding new Fields from the "Parent", but this isn't likely in your case because you're goal is to show "Child" node info.
  4. Place the Block on Listing Details nodes and adjust the Node from URL and other Block options.

Now you will see the Listing Premium Settings nodes on Listing Details nodes, but only the ones that reference the node you're currently viewing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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