You are here

function contemplate_examples in Content Templates (Contemplate) 7

Same name and namespace in other branches
  1. 5 contemplate.module \contemplate_examples()
  2. 6 contemplate.module \contemplate_examples()

Load an example node and display its parts

  • used only on template edit page

Parameters

$type: node type

Return value

an array containing the 'rss', 'body' and 'teaser' versions of the node

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

File

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

Code

function contemplate_examples($type) {
  $path = drupal_get_path('module', 'contemplate');
  drupal_add_js($path . '/contemplate.js');
  drupal_add_js($path . '/divresizer.js');
  drupal_add_css($path . '/contemplate.css');
  $recursion_limit_hit = 0;
  if ($views = contemplate_node_views($type)) {
    $settings = array(
      'contemplate' => array(
        'example_nid' => $views['body']->nid,
      ),
    );
    drupal_add_js($settings, 'setting');
    $boutput = contemplate_array_variables((array) $views['body'], 'bodyfield', FALSE, FALSE, 0, $recursion_limit_hit);
    $toutput = contemplate_array_variables((array) $views['teaser'], 'teaserfield', FALSE, FALSE, 0, $recursion_limit_hit);
    $routput = contemplate_array_variables((array) $views['teaser'], 'rss', FALSE, FALSE, 0, $recursion_limit_hit);
  }
  else {
    $error = t('No %type content items exist to use as an example. Please create a %type item and then come back here to see an output of its parts.', array(
      '%type' => $type,
    ));
    $toutput = $boutput = $routput = $error;
  }
  return array(
    'body' => $boutput,
    'teaser' => $toutput,
    'rss' => $routput,
    'body_krumo' => function_exists('kprint_r') ? kprint_r($views['body'], TRUE, '$node') : '',
    'teaser_krumo' => function_exists('kprint_r') ? kprint_r($views['teaser'], TRUE, '$node') : '',
  );
}