Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Feb 9th, 2010 | Syntax: PHP | Size: 1.64 KB | Hits: 78 | Expires: Never
Copy text to clipboard
  1. function recipe_view(&$node, $teaser = FALSE, $page = FALSE) {
  2.   if ($page) {
  3.     drupal_set_breadcrumb(array(l(t('Home'), ''), l(t('Recipes'), 'recipe')));
  4.     drupal_add_css(drupal_get_path('module', 'recipe') .'/recipe.css');
  5.   }
  6.   $node = recipe_node_prepare($node, $teaser);
  7.  
  8.   $node->content['recipebody'] = array(
  9.     '#value' => theme('recipe_node', $node, $page),
  10.     '#weight' => 1,
  11.   );
  12.  
  13.   return $node;
  14. }
  15.  
  16. function recipe_node_prepare($node, $teaser = FALSE) {
  17.   $node->readmore = TRUE;
  18.   if ($teaser == FALSE) {
  19.     $node->body = check_markup($node->body, $node->format, FALSE);
  20.     $node->instructions = check_markup($node->instructions, $node->format, FALSE);
  21.     if ($node->notes) {
  22.       $node->notes = check_markup($node->notes, $node->format, FALSE);
  23.     }
  24.     if ($node->source) {
  25.       $node->source = check_markup($node->source, $node->format, FALSE);
  26.     }
  27.     if ($node->ingredients) {
  28.       $tmp = $node->ingredients;
  29.       $node->ingredients = array();
  30.       foreach ($tmp as $ingredient) {
  31.         // For preview, node->ingredients is an array, for actual display, it's an object
  32.         if (is_array($ingredient)) {
  33.           if (isset($ingredient["name"])) {
  34.             $ingredient["name"] = check_plain($ingredient["name"]);
  35.           }
  36.         }
  37.         else if (is_object($ingredient) ) {
  38.           if (isset($ingredient->name)) {
  39.             $ingredient->name = check_plain($ingredient->name);
  40.           }
  41.         }
  42.         $node->ingredients[] = $ingredient;
  43.       }
  44.     }
  45.   }
  46.   else {
  47.     $node->teaser = check_markup("Click to see this recipe.", $node->format, FALSE);
  48.   }
  49.  
  50.   return $node;
  51. }