You are here

function editablefields_view in Editable Fields 6.3

Same name and namespace in other branches
  1. 6.2 editablefields.module \editablefields_view()

Menu callback: ajax view.

2 string references to 'editablefields_view'
editablefields_menu in ./editablefields.module
Implementation of hook_menu().
theme_editablefields_formatter_editable in ./editablefields.module
Theme the editable field.

File

./editablefields.module, line 416
Editable fields module.

Code

function editablefields_view() {
  $output = '';
  $nid = arg(1);
  $field_name = arg(2);
  $delta = arg(3);
  $node = node_load($nid);
  drupal_set_header('Content-Type: text; charset=utf-8');

  //  $html = node_view($node, FALSE, FALSE, FALSE);
  // this required traversing the entire node to get the field (and doesn't work
  // for checkboxes anyway)
  $field = content_fields($field_name, $node->type);
  $field['display_settings']['label']['format'] = 'hidden';

  // We have 2 reasonable choices here. We COULD use 'clicktoedit' and end up
  // with the same HTML - then we could strip that HTML down to remove the
  // surrounding 'click to edit' div (which we dont want, as we'll be replacing
  // the html inside one of those div's)
  // or we can simply use the 'defualt' formatter - which wont have the click to
  // edit inside it  - and is hard coded into this module (for now) anyway!
  $field['display_settings']['full']['format'] = 'default';
  $html = content_view_field($field, $node);
  $messages = drupal_get_messages('status', TRUE);
  if (count($messages) > 0) {
    foreach ($messages as $type => $messages) {
      foreach ($messages as $message) {
        $output .= '<div class="messages ' . $type . '">' . $message . "</div>";
      }
    }
  }
  $object = new stdClass();
  $object->content = $output . $html . drupal_render($node->content[$field_name]);
  drupal_json($object);
  exit;
}