Postponed (maintainer needs more info)
Project:
Node Relationships
Version:
6.x-1.5
Component:
Views integration
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
29 Jan 2010 at 16:01 UTC
Updated:
31 Jul 2011 at 12:07 UTC
Comments
Comment #1
markus_petrux commentedYou'll have to resolve this particular need using custom code. There are 2 steps:
1) Somehow, you need to alter the links opened in the modal frame adding URL arguments.
See the code in node_form.js. And here you should be able to find your way to alter the links used for each button (see the data structure in Drupal.settings.nodeRelationships), or you could replace the click handlers with your own, so you have 100% control to open the modal frame with the arguments you need.
2) Then you need to parse these arguments server-side and modify the view dynamically.
See: #589136: How to customize noderelationships views in real-time, when these views are executed
Comment #2
ethnovode commentedThank you for taking the time to answer. I'm not sure I'll be able to do this as I am very short on time and my php skills are not as good as I'd like. I still think this is a great module and I'll probably use it on another project.
Comment #4
tina650 commentedI believe I may be asking the same thing as ethnovode and so was hesitant to open a new issue.
I too need to limit the search and reference results by adding a noderef argument to the noderelationships_noderef view and Providing a default argument where the Default argument type is the Node ID from URL.
In my real life example, I am asking people to do a search and reference for an existing music venue (like a coffee shop or concert hall) while creating a new music event for a given town (nid is in the url). I would like the search results to be limited to the town and not display all venues in the entire state.
Since I'm a newbie, I'm hoping that I won't have to code as is suggested in http://groups.drupal.org/node/82219 Modify views filters programatically.
Thanks for your consideration!
Comment #5
tina650 commentedI suppose I should change the status?
Comment #6
markus_petrux commentedI'm afraid I do not have enough time for more, you'll have to code to implement your particular use case. Do you have any other particular doubt to get started? The basic idea on how to approach this issue has been described above, or in the thread you've linked to.
Comment #7
tina650 commentedAbout getting started, I'm not a developer, which makes this approach a bit intimidating for me right now. But then I wonder if it's not that difficult since there are others that want to do this and may have figured this out pretty easily. For example, someone asked for this in the Q&A part of this session, http://developedbymiche.com/blog/2010/04/18/drupalcon-sf-2010-views-exam....
If you have any helpful tips, I'd appreciate that.
Comment #8
tina650 commentedAs a temporary workaround, I added a relationship to my copy of the noderelationships_noderef view and added the field of the relationship as a filter. It's not elegant nor user-friendly and once there's a lot of data in there, it won't be feasible.
Would you consider adding this as a feature into your next release?
Comment #9
markus_petrux commentedNot strictly a dup, but closely related issue: #950098: hook_noderelationships_view_alter overrides are clobbered by views module
Comment #10
fourmi4x commentedI also needed this... struggled a few hours... and got it to work!!
1/ Modify the drupal_alter call (inside the function noderelationships_customize_noderef_view) in the noderelationships.inc file:
drupal_alter('noderelationships_view', $view_overrides, $view, $display_id, $view_args);becomes :
drupal_alter('noderelationships_view', $view_args, $view_overrides, $view, $display_id);because we need to change $view_args and not $view_overrides.
2/ In a custom module, as described in http://drupal.org/node/589136 (but we are also changing the variables' order of the function to get $view_args returned) :
So we get the new argument via the URL.
3/ You have to create two Global: Null arguments in your noderelationships_noderef view, before the third argument you want to pass (because two arguments are created by the noderelationships module, even if you can't view it on the view UI, hence the [2]). So the value you put in $view_args[2] will match the third argument of your view. With this technique, you can even apply relationships to your argument. This brings even more magic to the module :)
Hope that helps!
NB: I didn't manage to do this without hacking a core module file (noderelationships.inc) - Is there a way to avoid that?
Comment #11
markus_petrux commentedYou could also try using a hook provided by Views itself. See the file docs.php under the docs subdirectory of the Views package.
Comment #12
fourmi4x commentedThanks for this guideline, I'll dig into the views documentation, a thing I should have done earlier...