using contemplate with cck_field_perms
mdowsett - March 29, 2008 - 17:37
| Project: | CCK Field Permissions |
| Version: | 5.x-1.9 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
I am using contemplate with cck_field_perms...it seems like a dangerous combination.
When I don't adjust the template, the cck_field_permissions work properly. The user only sees and can edit the proper items.
But when I enable the "Affect body output" checkbox in the template, and don't change a thing in the code, the fields that are supposed to be blocked from view are now viewable! As I said, I didn't even change the code.
So is there extra PHP code that I need to surround the fields that I want it to listen to the CCK field permissions?

#1
From what I can tell this problem comes up because code that contemplate creates prints fields directly from the node object itself ( i.e. print $node->field_name[0]['view'] ) which overrides any access checking, templating, etc.
Meanwhile cck_field_permissions modifies $node->content, which is an array of field groups, which has and array of the fields in a group.
Inside the field array is [#access] and it seems CCK_field_permissions sets this to 1 or null based on the access rules for CCK_field_perms. With the devel module do a dpm($node->content) and you should see what I mean.
So basically you have to add a check of $node->content[field group][field][#access] to the contemplate.
#2
thank you... i simply thought I was crazy.
this has been an issue for me for a LONG time.
i also read about formfilter module.
I might try that also but I don't know if it works with contemplate.
Is this only for output?
How about the input pages?
#3
I also found that it works if you display the CCK field group.
http://drupal.org/node/135616
A little less themable but it does work.
Cheers,
Latte
#4
what do i do about things that are $node->links which do not have a $node->content entry?
Chris
#5
I am a little confused.
does this module restrict
1. who can view the elements on the form
2. restrict who can see a particular field on the node view
3. both
I am using content template. There are fields field_A, field_B that are on the input form.
field_A, field_B are for special admin, Editor, to fill in.
They do not show up on the node teaser or body page and I only want them to show up for Editor admin to fill in.
I have not included them on content template since CT only renders the node.
But the values are still viewable on the input page even after I selected the node and fields on the cck_fields_perm to restrict and given access only to Editor.
Am I missing something?
C
#6
3. both (I believe)
I stopped using CT on my site due to not being able to properly hide fields I had flagged with CCK Field Perms
#7
did you do any themeing of the site or the nodes? did you use node.tpl method? did that work and allow cck field permissions to work?
#8
i avoided doing any theming in order for the CT to work (that was a long time ago tho - so I hope things are improved now)