function recipe_html_export_single in Recipe 7
Same name and namespace in other branches
- 6 plugins/recipe_html.module \recipe_html_export_single()
- 7.2 modules/recipe_html.module \recipe_html_export_single()
1 string reference to 'recipe_html_export_single'
- recipe_html_recipeio in includes/
recipe_html.module - Implementation of hook_recipeio($type).
File
- includes/
recipe_html.module, line 34 - recipe_html.module - Enables a print view for recipes. This supports full 8-1/2" x 11", and 5"x7" and 3"x5" index cards. Some printers may not be able to deal with small page sizes like this. They may have to print on…
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']);
// Streamline the summary box.
$build['recipe_summary_box'] = array(
'#markup' => theme('recipe_html_summary_box', array(
'node' => $node,
'show_yield_form' => isset($node->recipe_show_yield_form) ? $node->recipe_show_yield_form : TRUE,
)),
);
// 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,
));
}