You are here

function recipe_html_export_single in Recipe 6

Same name and namespace in other branches
  1. 7.2 modules/recipe_html.module \recipe_html_export_single()
  2. 7 includes/recipe_html.module \recipe_html_export_single()

Example implementation of hook_perm(). If you need special permissions for a format, use this and match the permission name to the access arguments above.

function recipe_html_perm() { return array(t('export single')); }

1 string reference to 'recipe_html_export_single'
recipe_html_recipeio in plugins/recipe_html.module
Implementation of hook_recipeio($type).

File

plugins/recipe_html.module, line 39
recipe_recipeML.module - Enables importing and exporting of recipeML format recipes.

Code

function recipe_html_export_single($nid = NULL, $yield = NULL) {
  if ($nid === NULL) {
    drupal_set_message(t('Recipe not found.'));
    drupal_not_found();
    return;
  }
  $node = node_load(array(
    'nid' => $nid,
    'type' => 'recipe',
  ));

  // Set the custom yield so we can scale up/down the recipe quantities.
  $node->custom_yield = $yield;

  // Set yield_form_off to remove buttons.
  $node->yield_form_off = 1;

  // you should not be able to export unpublished recipes
  if ($node->status == 0) {
    drupal_access_denied();
    return;
  }

  // This calls other modules *_view hooks.
  $node = node_build_content($node, FALSE, TRUE);

  // Set the proper node part, then unset unused $node part so that a bad
  // theme can not open a security hole.
  $content = drupal_render($node->content);
  if ($teaser) {
    $node->teaser = $content;
    unset($node->body);
  }
  else {
    $node->body = $content;
    unset($node->teaser);
  }

  // Allow modules to modify the fully-built node.
  node_invoke_nodeapi($node, 'alter', $teaser, $page);
  $html = theme('recipe_export_html_page', $node);
  return $html;
}