- CCK form field changes using Drupal's hook_form_alter don't work? Use #after_build
- Views query substitutions in Drupal 6
- Should you be building your next website in Drupal?
- How to add Zoopy video to your Drupal site using CCK and the Embedded Media Field module
- My state of Drupal, today, 18 March 2009
- Drupal Johannesburg 11 March meetup notes
- Quick Drupal setup using Acquia's DAMP stack
- Drupal conference 2009 videos available on the Internet Archive
- Drupal 500 Internal Server Error on shared hosting
- The case for Drupal
How Drupal's CCK already provides a safely formatted cck field for display
Came across an interesting post when investigating some "n/a" text appearing in a CCK node field when not logged in. I was using the code echo content_format('field_description', $field_description[0]); to safely format and output the description field. Not sure exactly why it happens but it turns out that there's no need to actually do it that way as CCK already provides a safe string of that field for outputting to the browser that is already formatted accordingly. This is available in the $node array, in the 'view' value: [field_url] => Array ( [0] => Array ( [url] => http://www.cso.gov.bw/ [title] => [attributes] => [view] => http://www.cso.gov.bw/ ) ) So you only need to print $node->field_url[0]['view']; If you can't do this, you can still do it the other way, it seems by using the following: <?php echo content_format('field_description', $field_description[0], 'default', $node);?> But why do it again if it's already been done for you? Update: if not using a cck field, say in a custom module and you want to format a field you've fetched from the database, use the functions check_markup or check_plain
- Tags:
