4

So I'm trying to figure out how to filter a couple of entityreference view I'm using to populate an entityreference field. It has the option to pass arguments to the view, but I'm not sure HOW to do that.

In one node add/edit form I need it to take the values of two taxonomy terms. Those terms would then filter down the list and only return values that included those values. The Taxonomy terms can have three values though.

I also have another form that I need to be able to filter based on what name is in the Authored by Field. I need to be able to pass that back to the view and only return nodes that are authored by the authored by user.

I'm not sure how you set that up and I'm trying to find documentation to figure it out. So far no luck.

If anyone has any ideas, let me know.

4
  • only return values that included those values you mean return nodes that have those term names?
    – No Sssweat
    May 21, 2016 at 23:46
  • Pretty much yes. For the Writing Prompt Field it should return only WPs that contain any one value from Series and Genre on the Story Node that is being created. Same on the Chapter page, it should only return stories where the Author is equal to the authored by field. That one currently I have set to display anything by the current logged in user (Otherwise known as whomever is viewing the add/edit node at the time) but for admin uses I need the admin/editors to be able to see more then just there stuff.
    – CW Smith
    May 22, 2016 at 16:51
  • 1
    but for admin uses I need the admin/editors to be able to see more then just there stuff. checkout my answer to this similar question allow user to choose from his own referenced nodes the answer in here is for Drupal 7, not sure which version you're using.
    – No Sssweat
    May 23, 2016 at 0:30
  • I'm using Drupal 7.x as my current setup. This will eventually be ported over to D8 if I can ever figure out my navigation issues, but that's a different and separate thread. And the post you linked me to, if I'm reading it right, gets me most of the way there. There are actually times right now where the Admin will need to create a new chapter page so he'll be in the add/edit node form, but he's not the one whose story is being added to. Is there a way to tie this into the authored by field of the add/edit form?
    – CW Smith
    May 23, 2016 at 0:51

1 Answer 1

2

Add a contextual filter of Has Taxonomy Term ID

  • Select Provide Fixed Value and type Fixed Value. For fixed value type the ID's of your terms separated by a comma. (You can find the ID of your taxonomy terms inside the edit url when you edit your terms)

enter image description here

Scroll all the way down to the MORE section.

  • Click on MORE and check mark allow multiple values.

enter image description here


For your other view, use Author Uid and follow the picture below.

enter image description here

5
  • The top seems to be specific values though, numerical values. How does that set the value based on the fields being set in the form the entityreference field is part of? Also, User ID from URL troubles me as in some case you won't have that when an admin is adding a story for an account.
    – CW Smith
    May 23, 2016 at 9:07
  • How does that set the value based on the fields being set in the form the entityreference field is part of? so you want to filter based on the term names given to the node?
    – No Sssweat
    May 23, 2016 at 9:13
  • Yes, I want to filter the enetityreference fields list by the values entered in the node add/edit pages Series and Genre fields, it can have 3 values a piece.
    – CW Smith
    May 23, 2016 at 9:21
  • 1
    @CWSmith One problem, when you add a page, the page itself does not exist yet; thus, the values are not the DB yet, so it's impossible to load them and pass them to the view. The only workaround I see, would be use jQuery that sets a cookie based on the values filled out in Series and Genre fields. Unfortunately, today I don't have time to attempt to do that.
    – No Sssweat
    May 23, 2016 at 9:38
  • I get what you are saying there on that. I was just thinking it was possible if only because the settings in the content type shows a place to pass arguments to the view. So I figured if that were the dcase you could pass your arguments, the selected values for Genre and Series, to the entityreference view and pare your list down that way, at least for series. Author though yea, I'm just slamming my head in on that. once again I would think you could pass the argument back and forth, but I just am not sure HOW to do it properly.
    – CW Smith
    May 23, 2016 at 11:32

Your Answer

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

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