Drupal Views Relationships - drupal

I have the following problem:
I created content type "movies" and content type "actors". I added a node reference to the "actors" which links to movies. When i create new actor content I'm able to select movie from node reference. So, I created a list inside Views which shows you a list of actors and next to the actor it displays one of the movies they were in. I did this through node reference in "actors".
Ok, so here is the problem. I now want to create a list of movies and actor next to the movie. I know I can solve this problem if I create another node reference inside movies and every time I create movie content I would need to select actors attached to the movie. Is there a way to do what I need without creating another node reference. I want to use already existing node reference inside actors and show actor depending on the movie selected for the actor.
Can some one please help me with this problem? Im really stuck.
Thank You,
Toliy

You can install the nodereferrer module to provide a counterpart to the node reference fields. It makes node references accessible in both directions so you can do this sort of thing.

Just found out about this, which handles bidirectional relations.

I've also had a lot of success with the Corresponding Node Reference
After you set up your two node references, you can use simple checkboxes to ensure that they are linked up.

Related

Drupal 8 Views Question Involving Entity Reference

Trying to figure out views relationships and filters.
I'm trying to make a view that has the title of the page match the entity reference of the same page and make it reactive so I only need one. EX.) Page about animals, which there are nodes referencing the animal page as an entity reference.
Firstly, you have to take one unique field which can identify whether particular node is for animals or etc.
After that, In your views you need to select that field name in contextual filter and select option as you can see in screenshot and then save it.

Drupal views: list referenced nodes except the one used as contextual filter

i have the following case: I am building a website that has information on filmmakers and their films. I have a node type for the filmmaker, with biographical content, etc and another one for the films, with a field 'author' that references one or more of the filmmakers (since one film may have been made by several of them).
I also have a views block called 'filmography' that lists all the films whose author is the filmmaker (node) the user is seeing. Setting this up with a contextual filter was quite easy.
But now I want to present in this block along with the film name, all the filmmakers that may have made the film ('author' field in the film node) and that are different from the filmmaker being viewed. Displaying all the filmmaker nodes referenced by the author field is immediate, but I want to remove the filmmaker that I am using in the contextual filter. The goal is to get something like this:
Filmmaker 1
Movie 1
Movie 2 (with Filmmaker 2)
Movie 3
I have the notion that this might be done using views php and filtering the node references returned, but I wonder if there is an easier solution for that...
Thanks
Update: I have managed to get a result using the Views Field View module, passing the list of referenced nodes (filmmakers) as a contextual filter (node ID) and then adding another contextual filter (node ID as well) as an exclusion, and getting the default value of the letter from 'node id from URL option' (that is, from filmmaker's page the filmography view is embedded in). Keeping the question open for a while to get other, possibly more efficient, alternatives.
As I read your question, the Views Field View module popped into my mind as the obvious solution (then I saw your edit). I think this will still be your best bet. Definitely avoid using php fields as that is not a good practice in general from a security standpoint. If you are concerned about efficiency/performance, then you should just use views caching setting under the advanced options. Seems like this option is always looked over.
If you are looking for alternative options, one might be to use rendered nodes as your View style instead of fields, then use Display Suite to generate additional display modes beyond "Default" and "Teaser," create a view with the filters, then use the Entity Views Attachment (EVA) module to insert a view as a display mode field. While this is certainly a robust approach, it adds a lot of processing overhead with the rendered entities, so you definitely want to cache the results of that as well.
p.s. You might get faster/more responses over at https://drupal.stackexchange.com/

Can you create a joined view from task list and related content?

I'm trying to create a view of approval tasks that also includes a column from the related form library. I have tried creating a linked data source between the tasks list and the form library, but have trouble finding much information on creating linked views with the task list.
I have tried:
http://deannaschneider.wordpress.com/2012/07/25/joining-the-task-list-with-related-content-in-a-dvwp/
without luck - it just tells me "there are no items to show in this view." which I assume means it couldn't be joined correctly with the specified table.
I am using the standard approval workflow.
Here is the closest solution I've found so far
1.) Create task form fields in SharePoint designer.
2.) Go into Approval(1) to add the task form fields.
3.) Click 'Change the behavior of a single task'. Add 'Set task field' action in the Before a task is assigned section to set the task form fields to get the value of Current Item:ID.
4.) Use the new task field to create your subview on your linked datasource
While not optimal - and it created me many different problems - I was able to create the view desired.
Hopefully someone will come up with a better solution.

Drupal: relating two fields with each other

I have two fields: Supervisor and agent in a new content type. The list of agents depends on the supervisor selected. How can I create such a dependency i.e. each time a different supervisor is selected from a list a new list of agents is set?
Do I need to set up the supervisor and the agents each as nodes and then use entity reference?
How can I set up the dependency in the content type?
Cannot ask for clarification since I'm new here but here goes
Taxonomy terms can be a solution to the problem depending on the amount of information Supervisor and agent holds. If they hold information like phonenumbers, adresses, names etc. then they need a content type. If these are in fact references to users in the system then you need to use those users. If it's just for categorization, taxonomy terms will work just fine.
Set up the Supervisor as the parent term and the agents as children. Then use a widget like this one to handle the input: https://drupal.org/project/term_reference_tree
Afterwards you can retrieve and show data based on which term/agent is relevant.

Drupal: Display only specific NodeReferrer field in Views

I have a content type appointment with a date field that references nodes of the content type person using the Nodereference module. In the content type person I added a Nodereferrer field that shows the reverse of this references (Person -> appointments).
I now want to create a view of person nodes that shows the last appointment date of that person. I can create a View of persons with a relationship to appointments that displays all appointments, but I have no idea on how to display only the most recent one.
Any ideas on how to achieve this?
Personally I have not had much success with using views and node reference. It never seems to work out the relationships properly.
So my advice would be to write your own query. If you look here you can see a way to override the SQL generated by views, so you still get a lot of the goodness which comes with views.
By the way I would be very interest to see if there is a better answer than this
Instead of adding the Nodereferrer field to the view, try adding the Nodereferrer relationship then adding the Node title (using that relationship) as a field. You should be able to sort from newest to oldest, and then set the view to be Distinct so that only the first row for each person shows up.

Resources