You are here

function recipe_html_export_single in Recipe 7.2

Same name and namespace in other branches
  1. 6 plugins/recipe_html.module \recipe_html_export_single()
  2. 7 includes/recipe_html.module \recipe_html_export_single()
1 string reference to 'recipe_html_export_single'
recipe_html_recipeio in modules/recipe_html.module
Implements hook_recipeio().

File

modules/recipe_html.module, line 34
Enables a print view for 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($nid);

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

  // Remove the yield buttons.
  $node->recipe_show_yield_form = FALSE;

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

  // Don't pass to theme handlers.
  unset($build['#theme']);

  // Don't want to show links in print view.
  unset($build['links']);

  // Pass a fully rendered variable.  This is modeled after the book module in core.
  $node->rendered = drupal_render($build);
  drupal_add_http_header('Content-Type', 'text/html; charset=utf-8', FALSE);
  return theme('recipe_html_page', array(
    'node' => $node,
  ));
}