You are here

function contemplate_get_fields in Content Templates (Contemplate) 7

get fields for the template edit form

1 call to contemplate_get_fields()
contemplate_edit_type_form in ./contemplate.module
Menu callback Edit the template for a specific node-type

File

./contemplate.module, line 898
Create templates to customize teaser and body content.

Code

function contemplate_get_fields($type_name) {
  if (module_exists('field')) {
    $return = array();
    $return[] = '<?php $fields = field_attach_view(\'node\', $node, \'full\', \'en\'); ?>' . "\n";
    $instances = field_read_instances(array(
      'entity_type' => 'node',
      'bundle' => $type_name,
    ));
    foreach ($instances as $field) {
      $return[] = theme('contemplate_field', $field);
    }
    if (count($return)) {
      $return = implode("\n", $return);
    }
    else {

      // return, no instances were found but field module is enabled
      $return = FALSE;
    }
  }
  else {

    // no field module, dont bother
    $return = FALSE;
  }

  // field module was present and we found some fields and themed them
  return $return;
}