I'm sorry if this has already been answered, however I have searched this knowledge base and I have found articles that are the same as my problem, the only thing is, the solutions that have been identified, don't seem to work with my installation.
I have created a content type and I am trying to theme for that content type. I have created a node template file for the content type and have used the following line:-
<?php print content_format('field_bookhotelnowlink', $field_bookhotelnowlink[0], 'default', $node) ; ?>
When I call a node with this content type as an anonymous user, one of the fields is returned as n/a. The field in question is used by the admin to enter some HTML to create a button on content that is created by a registered user.
Any ideas or help would be gratefully appreciated.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | cck-text-na-435520.patch | 674 bytes | yched |
Comments
Comment #1
yched commentedLooks like check_markup ends up being called with $check param = TRUE.
text_field('sanitize') has :
I don't actually remember why we have this $check code, but since you're providing a $node to content_format().
Not much time to investigate right now, but you could try drirectly printing $field_bookhotelnowlink[0]['view'] instead.
Or use the $field_bookhotelnowlink_rendered variable, that contains the whole output for the field (including label and multiple values)
Comment #2
tsredman commentedFantastic!!! Thank you very much for your help. That works a charm.
Comment #3
yched commentedReopening + marked #458204: content_format() with text areas returns "n/a" if user doesn't have permission to use input format as duplicate.
As I said above, I see no reason why text_field($op = 'sanitize') should bother calling check_markup() with $check = TRUE when the node is being previewed.
I kind of vaguely remember mirroring this code after some core case (node body ?), which might have changed meanwhile. In current D6 core, node module doesn't bother with anything, and always renders the body with $check = FALSE.
The only core check_markup($check = TRUE) call in core is when generating a comment title out of a comment body (http://api.drupal.org/api/function/_comment_form_submit/6). Not even true in D7 anymore, since the $check param has been removed completely, and the corresponding code in http://api.drupal.org/api/function/comment_form_submit/7 calls a regular check_plain() without any format access check.
Pinging sun, which should have more accurate ideas than mine on this topic, but it looks like we could remove the $check param from that check_markup() call.
Comment #4
sunThe $check parameter is an old construct of pre-Form API times, in which not validated submitted form values were used to render a preview. The preview was generated during form processing/validation, so user access to the selected text format was not validated/verified/secured. $check had to be TRUE mainly for those invocations. Since no preview is generated in case of a form validation error today, the $check parameter is basically obsolete and therefore has been removed from D7: #446518: Remove $check argument from check_markup()
$check should always be FALSE when rendering a stored piece of text with an assigned text format, which has been properly validated before storage.
The only exceptions for passing $check = TRUE are:
1) when displaying a preview AND short-circuiting Form API validation. (i.e., rendering a preview despite a form validation error)
2) when filtering a text using an arbitrary format. This usage is completely wrong and bogus in the first place. The only location where this happens is for rendering text fields of Profile module in core, since Profile module does not store any text format for the field value.
Comment #6
eric_a commentedThis a really terrible...
Comment #7
yched commentedFinally fixed - committed the attached patch to both 2.x and 3.x branches.