You are here

function ds_render_code_field in Display Suite 7

Same name and namespace in other branches
  1. 7.2 ds.module \ds_render_code_field()

Render a code field.

2 calls to ds_render_code_field()
ds_dsc_content_type_render in plugins/content_types/dsc/dsc.inc
Output function for the 'Display suite' content type.
ds_get_field_value in ./ds.module
Get the value for a Display Suite field.

File

./ds.module, line 999
Display Suite core functions.

Code

function ds_render_code_field($field) {
  if (isset($field['properties']['code'])) {
    $format = isset($field['properties']['code']['format']) ? $field['properties']['code']['format'] : 'plain_text';
    if ($format != 'ds_code') {
      $value = check_markup($field['properties']['code']['value'], $format);
    }
    else {
      $value = ds_php_eval($field['properties']['code']['value'], $field['entity'], isset($field['build']) ? $field['build'] : array());
    }

    // Token support - check on token property so we don't run every single field through token.
    if (isset($field['properties']['use_token']) && $field['properties']['use_token'] == TRUE) {
      $value = token_replace($value, array(
        $field['entity_type'] => $field['entity'],
      ), array(
        'clear' => TRUE,
      ));
    }
    return $value;
  }
}