I have searched the forums/issues/google for this to no avail. Running D6.10 and CCK6.x-2.2
I want to allow authenticated users to input using Full HTML. That HTML should then be READABLE to anonymous users, who are only allowed to input using very a stripped-down 'simple HTML' format which is also the default input format. This is working normally with title and body fields.
However, CCK textarea fields behave differently. They will only display the Full HTML if the user is authenticated and logged in. Anonymous users see "n/a". If I copy the same HTML into the body field it is viewable to anonymous users. The field's 'Text processing' is set to 'Filtered text'.
What is really bizarre is that this is only happening when I re-submit nodes. Some nodes which have not been re-submitted for a long time will still have their 'descriptions' visible to anonymous users. If I resubmit them as (their current format) Full HTML, they become "n/a" and if I resubmit them as Simple HTML they lose their formatting.
I have tried clearing cached data and running update.php. I have tried the Better Formats module. I have tried creating new CCK fields. All to no avail. Any advice appreciated.
All I am actually trying to achieve is to restrict anonymous users and their comments to minimal HTML...whilst allowing them to view content posted with full HTML. It shouldn't be this difficult, should it?
Comments
Comment #1
Stephen Scholtz commentedI just ran into this same problem, and it seems to only be an issue if you're trying to use
content_format()on your text area.The value of the text area is available be referring to it directly...
...and can be found inside the basic
$contenttheme variable, regardless of what input format was used on the text area and what input formats the user (in my case, anonymous users) have access to.But as described above, if the anonymous user doesn't have permission to use the "Full HTML" filter, and some text area content has been saved using that format, using
content_format()to theme this text area content will only return a "n/a" to anonymous users.I dug through the code, and the issue seems to be related to CCK's text.module "sanitize" action. (I believe #435520: Theming with content_format getting fields with n/a is the same issue, which wasn't resolved but set to closed anyways) There's a call to
check_markup()that will also runfilter_access(), which checks to see if the user has access to the input format being used on that text area. The end result is that the 'safe' value of the returned item is set to "n/a" by this sanitization, andtheme()uses that value to return the final display code.I'm not sure if this is a bug or a feature, or an edge case, but it's definitely a confusing behaviour for themers, I would think.
Thoughts?
If you're a themer and you've come across this thread, refer to the CCK field directly as above instead of using
content_format().PS - Does the $field_[fieldname]_rendered variable referred to in #435520: Theming with content_format getting fields with n/a actually exist? I tried it with CCK 2.7 and didn't get anything.
Comment #2
yched commentedShould work if you provide the $node parameter to content_format().
$field_[fieldname]_rendered : yes, if your field name is field_foo, $field_foo_rendered variable should be available in node.tpl.php
Yet, true, this 'n/a' behavior is caused by code which I cannot find any justification for.
Reopened #435520: Theming with content_format getting fields with n/a, and marked this one as duplicate.
Comment #3
yched commented