Posted by develCuy on November 14, 2008 at 2:08am
| Project: | Content Construction Kit (CCK) |
| Version: | 6.x-2.6 |
| Component: | nodereference.module |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (won't fix) |
Issue Summary
Views.module provides a textarea of PHP code for arguments, this patch adds just same feature for nodereference.module fields associated to views.
Comments
#1
Here the patch with an screenshot for rounding the idea.
#2
Here is the updated to 6.x-2.x-dev version, sorry I don'w know how to make a diff on...ermm...windows.
#3
Created a patch and fixed a logic error. Now the php textarea is given priority over the textfield, as per the original patch intentions.
#4
Works great, just what I needed, thanks develCuy & cristopher_skauss
#5
Regarding #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
#6
views version?
#7
Tracking...
#8
subscribing
#9
When 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?
#10
I'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...
#11
I have tested this patch on CCK 6.x-2.3 and it works correctly. Very useful.
Can we please have this committed asap.
#12
/subscribre
Quite simple to patch, very low possibilites to break another functionnality, I think it can be commited.
#13
subscribing
#14
subscribe
#15
Subscribing...
#16
Maintainers: could we please have this committed?
#17
The 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)?
#18
Subscribing...
#19
Subscribe
#20
could this be done for the userreference module as well?
#21
@keyser79 you pointed it right. We need this feature for all cck fields linked with views, is so handy and useful.
Blessings!
#22
I 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:
return array('0'=>'4');I have tried..
$arr = array();$arr['first'] = 123;
return $arr['first'];
And as many different combinations as I could think of to try and get something to return.
Thanks!
#23
I fixed it. It turns out I didn't apply the patch properly.
#24
subscribe
#25
subscribe
#26
I 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);
#27
If 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?
#28
Could we please have this committed. Thanks.
#29
#30
subscribe
#31
subscribe
#32
The 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.
#33
When 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.
#34
I understand what is your feeling and I think that is good to postpone this feature request, perhaps will make sense later.
#35
If 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.
#36
I 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 ?
#37
I've figured out how to do what I need thanks to Advanced Help for views:
Thanks views maintainers for this useful feature.
#38
This 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.
#39
For 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 :
<?php$arg=array();
$arg=explode('/', referer_uri());
return $arg[6];
?>
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.
#40
subscribe
#41
Just 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
if($_GET['gids']) {return implode(",", $_GET['gids']);
} else if ($group = og_get_group_context()) {
return $group->nid;
}
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?