Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello!
Thank you for very good module!
I create clone of noderelationship_noderef view that should filter only nodes that are not refferenced yet. For some reason that should be very simple (but not clear for me) I can not see any back_reference fields in Relationships or in Filters part of View. How can I filter referenced nodes by back reference fileds in Views?
Comments
Comment #1
markus_petrux CreditAttribution: markus_petrux commentedI'm afraid this is not possible from Views UI with current features of Node Relationships module. This needs coding.
A bit of explanation on where we are:
The Node Relationships module does not add CCK fields to duplicate back reference data like in Nodereferrer or BackReference modules.
The back references provided by Node Relationships module are just views that filter data from node reference fields to display a list of back references from referred nodes. You can customize this kind of views as CCK fields, but this is just to allow you place the rendered output of these views in the node view from the "Manage fields" page. These are not real CCK fields.
The dynamic customization of views used for "Search and reference" feature just add a couple of fields (nid and title) so that the jquery stuff in the modal frame dialog can build the value for the node reference field, and then a filter per node types is also added dynamically. You may want to add more filter here to suit your needs.
Arguments for noderelationship_noderef views are also built dynamically. We are using the type of the referrer node (first argument) and the name of the nodereference field in the referrer type (second argument). These arguments are needed for all these dynamic customizations to take place in real-time, when the view is executed.
All these dynamic customizations happen in
noderelationships_customize_noderef_view()
located innoderelationships.inc
. Close to the end of this function there is a drupal_alter() that provides a method to further extend these dynamic customizations. The prototype of this hook looks like this:So to solve this problem you need to code, and this is the hook that should allow you to do this. I hope that helps.
Comment #2
olegvo CreditAttribution: olegvo commentedMarkus,
Thank you!
Comment #3
markus_petrux CreditAttribution: markus_petrux commentedYou're welcome.
I marking this fixed and I'll also add a link in the project page because this kind of documentation is not already provided.
Comment #4
markus_petrux CreditAttribution: markus_petrux commentedBetter title.
Comment #5
markus_petrux CreditAttribution: markus_petrux commentedComment #7
markus_petrux CreditAttribution: markus_petrux commentedRelated issue: #950098: hook_noderelationships_view_alter overrides are clobbered by views module
Comment #8
dsayswhat CreditAttribution: dsayswhat commentedTurns out the related issue above was user error ( my user error, to be exact ) due to not carefully reading the documentation on hook_noderelationships_view_alter.
To get things working, be sure to modify the $view_overrides argument passed into the hook, rather than trying to edit the view directly using the normal views API methods.