You are here

function contemplate_examples in Content Templates (Contemplate) 5

Same name and namespace in other branches
  1. 6 contemplate.module \contemplate_examples()
  2. 7 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 'body' and 'teaser' versions of the

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 594
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)) {
    $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;
  }
  if ($recursion_limit_hit) {
    drupal_set_message(t('While traversing node variables your recursion limit of %limit was hit %recursion_limit_hit times. For more information about this error goto ' . l('http://drupal.org/node/230885', 'http://drupal.org/node/230885') . '. This issue will not effect the operation of Content Template, but it may not show you all available variables on this page. This message will only appear on this page.', array(
      '%limit' => variable_get('contemplate_max_recursion_depth', 10),
      '%recursion_limit_hit' => $recursion_limit_hit,
    )));
  }
  return array(
    'body' => $boutput,
    'teaser' => $toutput,
    'rss' => $routput,
  );
}