Drupal: Display only specific NodeReferrer field in Views - drupal

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.

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.

how to merge entity reference relationship field value

I am facing problem in drupal views.
In my view display table having relationship with other entity type.
I am not getting desire output. It show duplicate rows with same title due to entity relationship.
I wanted to aggregate entity relationship field with ",".
I already try some module like : view distinct, views_merge_rows.
But did not work for me.
Please suggest some module.
Have a look at Views Calc and if you cant do it in the database Views Aggregator Plus gives you even more options.

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/

Drupal Views Relationships

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.

Using Node Reference without popup?

I am using two content types company and Employee . I am using node reference here(Company -> Employee). Within the Company form , the Employee node comes as a popup ,Employee form need to bring the display and functionality to the company form and should keep the node reference. .
Unfortunately, embedding one form in another is nearly impossible in Drupal. That is due to its form-handling and node-handling system.
If you want such relationships, you often need to write a simple, small module that maintains relationships in the database, offers forms to insert/update them and ways to extend nodes with your relational behaviour.
Best I could suggest is an iFrame holding the employee form - but still it's not very elegant.

Resources