I was wondering if it would be possible to filter the node reference items by uid (i.e. currently logged-in user). So lets say we have a photo community site and each user creates their own photo album. And each photo upload section will have a node reference field indicating which user-created album to associate the photos with. If their was no filtering here, than Sally's albums (i.e. Paris, Bali) might show up along with Billy's albums (i.e. Hawaii, Spain) in the node reference field. I would like to be able to have only Sally's albums show in the node reference field when she is logged in and is uploading a photo. I would like only Billy's albums to show in the node reference field when Billy is the logged in user.
Does anyone know if this functionality is possible with the node reference set-up?
-Bao
Comments
Comment #1
karens commentedYou would have to do this with Views somehow. The nodereference module has an option to use Views for its list, but that is not working in HEAD because Views is not yet working for D6. Once we get Views working and update the Views integration, you'd use Views to filter your options.
Comment #2
karens commentedThis is not really a CCK issue, since it would require a Views solution.
Comment #3
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #4
MauMauWhen making a nodereference field in a content type you are asked which nodes the user should be able to choose from.
Usually you say "nodes with content type story, image" using the checkboxes.
You can refine it though, and say "nodes supplied by view [name og view]"
But is it possible to refine it even more?
A view can possess filters. I.e. when you ask for displayimages?filter0=5 you see images of chocolate (termid 5), when you ask for displayimages?filter0=11 you see images of fruit (termid 11).
I'd like for the nodereference field on my story about chocolate to pass the termid (5) to the view/nodereference field so that the user can only select images with termid5.
Having the nodereference field show all 10.000 pictures on the site every time you want to make a nodereference is just way to much.
Can views filters ever work for nodereference fields?
Comment #5
verres commentedDid you ever get any responses to this? I need to be able to do this as well - can't figure how to limit the nodes that show up in the node_reference autocomplete field.
thanks,
c
Comment #6
yched commentedYou need define a view that filters nodes created by the current user (doable using a relationship on 'Node Revision : User' and a filter on 'User : Current')
Then you use that view to define the nodes that can be referenced in this noderef field.
Comment #7
tindo commentedThanks yched
Comment #8
Bairnsfather commentedTo see yched's directions (#6) fleshed out courtesy webchick: http://drupal.org/node/617754
Comment #9
homeshop commentedThank you. It's working like a charm. I have been searching for this for a couple of days.