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.
Views.module provides a textarea of PHP code for arguments, this patch adds just same feature for nodereference.module fields associated to views.
Comment | File | Size | Author |
---|---|---|---|
#10 | Content-Construction-Kit_334121_10.patch | 2.7 KB | BWPanda |
#3 | nodereference.patch | 2.93 KB | chrisroditis |
#2 | nodereference.module | 8.83 KB | chrisroditis |
#1 | nodereference-module.patch | 2.96 KB | DevElCuy |
#1 | nodereference_view_arguments_php.png | 24.5 KB | DevElCuy |
Comments
Comment #1
DevElCuy CreditAttribution: DevElCuy commentedHere the patch with an screenshot for rounding the idea.
Comment #2
chrisroditis CreditAttribution: chrisroditis commentedHere is the updated to 6.x-2.x-dev version, sorry I don'w know how to make a diff on...ermm...windows.
Comment #3
chrisroditis CreditAttribution: chrisroditis commentedCreated a patch and fixed a logic error. Now the php textarea is given priority over the textfield, as per the original patch intentions.
Comment #4
pcambraWorks great, just what I needed, thanks develCuy & cristopher_skauss
Comment #5
arcane CreditAttribution: arcane commentedRegarding #2, when I try to configure my nodereference, I get the error on D6:
Fatal error: Call to a member function get_option() on a non-object in /var/www/ccpresscred2.flash4play.com/public_html/sites/all/modules/views/includes/view.inc on line 1772
Comment #6
chrisroditis CreditAttribution: chrisroditis commentedviews version?
Comment #7
chaloalvarezj CreditAttribution: chaloalvarezj commentedTracking...
Comment #8
ntt CreditAttribution: ntt commentedsubscribing
Comment #9
ntt CreditAttribution: ntt commentedWhen using PHP code to set the title of a CCK node, or setting the value of a computed field, the $node variable is avaible to be used... It would be good to have the same thing for setting the view arguments of node/userreference fields?
Comment #10
BWPanda CreditAttribution: BWPanda commentedI've tested this module and it seems to work well!
I've updated the patch for the latest version of CCK 6.x-2.x-dev (dated 2009-Apr-24) and attached it below.
It'd be good to get this committed...
Comment #11
superstar CreditAttribution: superstar commentedI have tested this patch on CCK 6.x-2.3 and it works correctly. Very useful.
Can we please have this committed asap.
Comment #12
zmove CreditAttribution: zmove commented/subscribre
Quite simple to patch, very low possibilites to break another functionnality, I think it can be commited.
Comment #13
kruser CreditAttribution: kruser commentedsubscribing
Comment #14
alvinet CreditAttribution: alvinet commentedsubscribe
Comment #15
paganwinter CreditAttribution: paganwinter commentedSubscribing...
Comment #16
superstar CreditAttribution: superstar commentedMaintainers: could we please have this committed?
Comment #17
michaelhall CreditAttribution: michaelhall commentedThe patch works great for providing php arguments for the advanced node reference using a view, but I lose the ability to upload files to any custom content type in which the node reference php arguments are applied.
Is there any progress in providing a fix for the file upload issue caused by the current patch (Content-Construction-Kit_334121_10.patch)?
Comment #18
paganwinter CreditAttribution: paganwinter commentedSubscribing...
Comment #19
nyl_auster CreditAttribution: nyl_auster commentedSubscribe
Comment #20
keyser79 CreditAttribution: keyser79 commentedcould this be done for the userreference module as well?
Comment #21
DevElCuy CreditAttribution: DevElCuy commented@keyser79 you pointed it right. We need this feature for all cck fields linked with views, is so handy and useful.
Blessings!
Comment #22
ifoundthetao CreditAttribution: ifoundthetao commentedI can't seem to get this to work. I patched it, but I can't get any results from it. Any thoughts?
Here's my code:
I have tried..
And as many different combinations as I could think of to try and get something to return.
Thanks!
Comment #23
ifoundthetao CreditAttribution: ifoundthetao commentedI fixed it. It turns out I didn't apply the patch properly.
Comment #24
ccshannon CreditAttribution: ccshannon commentedsubscribe
Comment #25
Breakerandi CreditAttribution: Breakerandi commentedsubscribe
Comment #26
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedI am a little confused. How can I pass the node author id as an argument?
I have a nodereference
I have assigned a view
I need to pass the node author of the current node to pull up all stories authored by the current nodes author.
On the node edit form for a node, is $node already known?
return array('0'=>$node->uid);
Comment #27
daggerhart CreditAttribution: daggerhart commentedIf this is on a node/add page, there isn't a node to pull an author from. You would need something like;
global $user;
return array('0'=>$user->uid);
The current user should also be the author of the added node.
If you're changing the author name when posting, you probably want a different solution. A view by itself could accept the $node->uid argument when presented on the node. You do this by changing the Validator to PHP Code in the view, and putting your current code in.
Did this answer the question?
Comment #28
superstar CreditAttribution: superstar commentedCould we please have this committed. Thanks.
Comment #29
Jackl85 CreditAttribution: Jackl85 commentedComment #30
sarandi CreditAttribution: sarandi commentedsubscribe
Comment #31
cliff_locus CreditAttribution: cliff_locus commentedsubscribe
Comment #32
KarenS CreditAttribution: KarenS commentedThe status 'to be ported' makes no sense here. It is not necessary to put [MAINTAINERS] into the title. #17 says there is a bug and no one addressed that issue.
Don't know if we want to support a new feature like this. Every place we allow people to add PHP code ends up creating lots of support issues from people who don't know how to use it. I'll let the other maintainers say what they think, but we are really trying not to add new features this late in the cycle.
Comment #33
markus_petrux CreditAttribution: markus_petrux commentedWhen you need to do something, there are often many ways to do it. Here we could have a way to do something that does not seem to add value compared to other ways to do it. Views provides hooks that can be used to alter the args, so I'm not sure this feature is really needed. I also think it may cause more headaches than benefit.
Comment #34
DevElCuy CreditAttribution: DevElCuy commentedI understand what is your feeling and I think that is good to postpone this feature request, perhaps will make sense later.
Comment #35
KarenS CreditAttribution: KarenS commentedIf I mark it postponed that indicates to people who come upon the issue that there is an intention to add it later. At this point there is not, so I'm marking it won't fix.
If there is some reason to revisit this later (not sure what that would be) it can be reopened or a new issue opened.
Comment #36
webel CreditAttribution: webel commentedI am really interested in this feature.
@markus_petrux
Could you please give (or link to) an example showing how to filter nodes available for selection according to a node id ? For example, I want only child nodes of a given node to be available for selection. How do achieve the same as passing an %nid from the Views argument field ?
Comment #37
webel CreditAttribution: webel commentedI've figured out how to do what I need thanks to Advanced Help for views:
Thanks views maintainers for this useful feature.
Comment #38
artsy.ca CreditAttribution: artsy.ca commentedThis thread is indicative of a recurring issue in Drupal that keeps haunting us to this day:
Having to create custom node types that duplicate functionality when all we want is some simple variation.
Here is an example:
I have node type: "movie" with taxonomy: "genre": "horror", "action", "comedy" etc.
I have node type: "movie list" with a node reference to a list of movie nodes and also the same taxonomy as above.
I want movie list:horror to only display movie:horror in its node reference, likewise "action", "comedy", "etc"
If there were some way to pass a parameter to the view that is equal to the current node's taxonomy field, then I could have just two kinds of nodes.
This however is seeming to be impossible, so instead I have to create infinite content types, each identical except for one parameter.
The added complexity is enormous and it totally sucks. It leads to duplication not only here but also in the templates and menu items.
Comment #39
eme CreditAttribution: eme commentedFor those who need this functionnality, it seems this can work will using Views arguments. I'm just testing this...
Example :
I want my user reference field to filter on a taxonomy term.
I pass this through the URL (node/add/page/taxo-term).
My node reference relies on a view with an argument taxonomy : terM
The you just put the default argument in PHP :
Referer_uri just fetch the complete URL of your page, and the other just fetch the "taxo-term" part. You can adapt it of course.
Then the user reference field will be filtered.
Comment #40
clashar CreditAttribution: clashar commentedsubscribe
Comment #41
daggerhart CreditAttribution: daggerhart commentedJust beating a dead horse here.
I needed this functionality again with a Content type within an OG Group. When creating a node within a group, I wanted the node reference to only see nodes in this Group.
Instead of using this patch, I was able to work around the issue with a views argument.
Argument: Organic Groups: Groups
Default if argument not present : PHP Code
Allow Multiple Arguments
I'm sure there are many drupalers that will tell me how terrible this is, but I don't see another way around it without applying this old patch.
Any other thoughts on how to accomplish this? Or is this a dead issue since the release of D7?
Comment #42
bsandor CreditAttribution: bsandor commentedI tested on userreference 6.x-2.9. It is working fine.
Wonderful feature.
------------------------
I run into a problem dough:
I'm on a node edit form. My code needs to get the node id that I'm editing so I make a query that gives me back an og id. This is what I'd like to send.
Anyways: I need to get the node id of an edit form with current php code.
I spent lots of time, couln't get it. Does somebody have an idea please?
Thanks in advance.
Comment #43
bsandor CreditAttribution: bsandor commentedI put these functions into my code and none of them worked:
og_get_group_context()
arg(1)
Is it related to this module or to a node edit form?
When I set these manually (equal to my group id OR argument 1) , the php code sends correct arguments to the view.
Why this php code can't get the output of these functions? Any idea?
Comment #44
Gomu CreditAttribution: Gomu commentedPatch in comment #3 worked fine. Thanks.