Closed (fixed)
Project:
Content Construction Kit (CCK)
Version:
6.x-2.x-dev
Component:
nodereference.module
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
6 Jun 2009 at 11:13 UTC
Updated:
13 Jun 2011 at 16:10 UTC
Comments
Comment #1
dawehnerits the normal behaviour to show the nodes, wether they are published or not.
but you can theme the formatters and check whether the content is published, or better whether the current user has access to the node via node_access
Therefore you would have to override:
theme_nodereference_formatter_default
theme_nodereference_formatter_plain
or
theme_nodereference_formatter_full_teaser
depend on which formatter you want to use
Comment #2
thommyboy commentedthanks- i would have expected "normal" behaviour to check for published but sure it can be solved the way you described...
Comment #3
karens commentedYou should also be able to add a relationship to the referenced node and then add a published=true filter for the related node.
Comment #4
thommyboy commentedthanks karenS, that's a good idea!
Comment #5
kforge commentedUse the Contemplate module. Click the template tab to edit your node type. For example, if I created one CCK nodeaccess field called "field_nodereference", it would appear in the body template as something like $node->field_nodereference[0]['view']. Find this field item in the body template, and wrap it in a conditional expression:
Existing field item output:
Modified output (which will disable the appearance of unpublished nodes):
Comment #7
remaye commentedSorry to post in this issue about 2 years later,
I tried to use advice at #1 and in my case node references are displayed as full nodes, so I tried to override "theme_nodereference_formatter_full_teaser" and it's not working : "mytheme_nodereference_formatter_full_teaser" is not called.
If I display node references as "title" or "title with link" and override "theme_nodereference_formatter_default" or "theme_nodereference_formatter_plain" this is working well.
I'm not a Drupal expert but I'm suspecting the way hook theme for "nodereference_formatter_full_teaser" is defined does not allow the function to be themable... What do you think ?
Thanks for helping
Comment #8
vegantriathleteDuplicate of node/1183758
Comment #9
vegantriathleteOoops! I didn't actually need to change the status on the last comment. Placing it back in its previous state.