1

I've been trying to figure this out for a while now, I believe that this should be easy but I still can't solve it. I'm a beginner at this. -_-

I have 3 Content types

  1. Venue
  2. Food
  3. Package

I have a List of Venue that will be used as reference for the Food. So, The Food content type has an entity reference field -> field_venue

The Food will only be available to the venue it referenced.

The Package Content type has the entity reference Venue and Food. It shows the venue and the food available.

I use Entity Reference View Widget for the Entity reference on Package Content Type. The Venue is working well.

My Problem is the Food.

I need an Entity Reference View Widget (VIEW) that shows the available food for the Venue.

On the form, the user will only be able to answer the Venue field. After that the form will be saved and the entity reference field for Food will display on the page, that is the place where the user will answer that field.

On the entity reference view widget Food, I have the following:

Filter Criteria: Content Type: Food

Relationship: Entity Reference: Referenced Entity (field_venue) marked as required

The problem is that the view shows all the food even if the chosen venue is not available for that food. I don't know where to put that condition. Either on contextual filter or Filter Criteria. I'm not sure. I just need the view to get the Answer of the Venue from that same form/node so that the Food will filter automatically.

Is there anyone that will be able to help?

Thank you very much!!!

1

I got this working with this set up:

Contextual Filter: field_venue -> Provide default value ->PHP Code -> PHP contextual filter code

$node=menu_get_object(); return $node->field_venue_for_catering['und'][0]['target_id'];

  • "field_venue" is the venue field from "Food"
  • "field_venue_for_catering" is the venue field from "Package".
0

Not exactly what you want, but you could try adding a filter criterion on Venue to the Food View and expose the criterion. That way the user can filter Food manually in the widget.

  • Thank you for your answer, I've tried that. But I think the form will become redundant..? because the user will need to choose the venue twice. But thank you for your suggestion! ^_^ – Danz Feb 6 '15 at 2:01
0

I needed to filter a view based on a Taxonomy field in a content type. I found a way to do that and it's very easy.

1- make a contextual filter -> select provide default value.

2- select type -> Taxonomy term id from url, you will get new checkboxes appeared below it.

3- check the following: Load default filter from term page, Load default filter from node page, that's good for related taxonomy blocks, Limit terms by vocabulary.

4- select the Vocabulary you want to filter based on.

5- Multiple-value handling: Filter to items that share all term.

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.