I'm really enjoying Field Collection so far, but I've run into the issue that I only want the field collection to be displayed as part of the node its embedded on. Due to my use case, I don't want the field collection displayed separately at /field-collection/field-name/[id].
The reason is that this particular field collection is used on a node with access control (using the Content Access module) to keep things private. So I don't want the field collection visible to users who don't have access to that particular node. Is there any way to keep the entity hidden at /field-collection/field-name/[id]? This would be similar to how nodes can be "unpublished" except that it would work on the field collection entity itself (and obviously the field collection would still need to be visible when displayed on an embedded node).
Does this seem like a doable feature request? Or is there some way currently to accomplish this?
Thanks,
Ben
Comments
Comment #1
tim.plunkettYou could use
hook_menu_alter()to set the access callback to FALSE for all of those callbacks, something like this:Comment #2
BenK commentedThanks! Very helpful.
Just one quick follow-up question: If I wanted to allow just those with the 'administer nodes' permission to be able to access /field-collection/field-name/[id] (and deny everyone else), how would I do that?
Thanks again,
Ben
Comment #3
tim.plunkettThat should just be like this:
See
hook_menu()for more details.Comment #4
BenK commentedThanks so much! Will try it out now...
--Ben
Comment #6
BenK commented@tim.plunkett:
Hope all is well. I've tried out your code suggestions and got some mixed results.... the code in comment #1 (deny access to all) worked fine, but when I try the code in comment #3 (grant access only to those with adminster nodes permission), I get the following notices:
Notice: Undefined index: access in _menu_translate() (line 778 of /Users/benkaplan/git/commerce_quickstart12j/includes/menu.inc).
Notice: Undefined index: access in menu_get_item() (line 464 of /Users/benkaplan/git/commerce_quickstart12j/includes/menu.inc).
Notice: Undefined index: access in menu_local_tasks() (line 1964 of /Users/benkaplan/git/commerce_quickstart12j/includes/menu.inc).
Notice: Undefined index: access in _menu_link_translate() (line 913 of /Users/benkaplan/git/commerce_quickstart12j/includes/menu.inc).
Notice: Undefined index: access in menu_set_active_trail() (line 2316 of /Users/benkaplan/git/commerce_quickstart12j/includes/menu.inc).
Additionally, access isn't actually granted to those with the administer nodes permission and the "View" tab isn't visible either for those with that permission.
Any ideas on how to fix?
Thanks again! :-)
--Ben
Comment #7
tim.plunkett@BenK, those should have been "user_access" not "user access", I apologize. I've updated the code above.
Comment #8
13rac1 commentedSeems fixed.