You are here

function contemplate_ajax_preview in Content Templates (Contemplate) 7

provide ajax callback for template editors

1 string reference to 'contemplate_ajax_preview'
contemplate_menu in ./contemplate.module
Implements hook_menu().

File

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

Code

function contemplate_ajax_preview($node, $type) {
  $template = file_get_contents('php://input');
  $node->build = node_view($node, $type);
  $xml_elements = array();
  $fieldset = array(
    '#type' => 'fieldset',
    '#title' => t('Content Template results'),
    //'#description'  => t('This is how your content will look after the template is applied, except some CSS differences.'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#value' => contemplate_eval($template, $node, $xml_elements),
  );
  $data = array(
    'messages' => theme('status_messages', array()),
    'content' => theme('fieldset', array(
      'element' => $fieldset,
    )),
  );
  drupal_json_output($data);
}