Untitled
By: a guest | Feb 9th, 2010 | Syntax:
PHP | Size: 1.64 KB | Hits: 78 | Expires: Never
function recipe_view(&$node, $teaser = FALSE, $page = FALSE) {
if ($page) {
drupal_set_breadcrumb
(array(l
(t
('Home'), ''), l
(t
('Recipes'), 'recipe')));
drupal_add_css(drupal_get_path('module', 'recipe') .'/recipe.css');
}
$node = recipe_node_prepare($node, $teaser);
$node->content['recipebody'] = array(
'#value' => theme('recipe_node', $node, $page),
'#weight' => 1,
);
return $node;
}
function recipe_node_prepare($node, $teaser = FALSE) {
$node->readmore = TRUE;
if ($teaser == FALSE) {
$node->body = check_markup($node->body, $node->format, FALSE);
$node->instructions = check_markup($node->instructions, $node->format, FALSE);
if ($node->notes) {
$node->notes = check_markup($node->notes, $node->format, FALSE);
}
if ($node->source) {
$node->source = check_markup($node->source, $node->format, FALSE);
}
if ($node->ingredients) {
$tmp = $node->ingredients;
$node->ingredients = array();
foreach ($tmp as $ingredient) {
// For preview, node->ingredients is an array, for actual display, it's an object
if (isset($ingredient["name"])) {
$ingredient["name"] = check_plain($ingredient["name"]);
}
}
if (isset($ingredient->name)) {
$ingredient->name = check_plain($ingredient->name);
}
}
$node->ingredients[] = $ingredient;
}
}
}
else {
$node->teaser = check_markup("Click to see this recipe.", $node->format, FALSE);
}
return $node;
}