function pagepreview_node_form_build_preview in Page Preview 7
Same name and namespace in other branches
- 6 pagepreview.module \pagepreview_node_form_build_preview()
Alternate submit callback for the node form "Preview" button.
1 string reference to 'pagepreview_node_form_build_preview'
- pagepreview_form_alter in ./
pagepreview.module - Implements hook_form_alter().
File
- ./
pagepreview.module, line 40 - An alternative node previewing system for the node add/edit form.
Code
function pagepreview_node_form_build_preview($form, &$form_state) {
$node = clone node_form_submit_build_node($form, $form_state);
$node->pagepreview = TRUE;
// Get the expected URL alias from Pathauto, if applicable.
if (module_exists('pathauto') && (!isset($node->path['pathauto']) || $node->path['pathauto'])) {
module_load_include('inc', 'pathauto');
$src = "node/" . $node->nid;
$alias = pathauto_create_alias('node', 'return', $src, array(
'node' => $node,
), $node->type, $node->language);
if ($alias) {
$node->path['alias'] = $alias;
}
}
// Cache the temporary node and active the preview area of the node form.
$preview_id = md5(json_encode($form_state['values']) . mt_rand());
cache_set($preview_id, $node, 'cache_pagepreview', CACHE_TEMPORARY);
$form_state['node_preview'] = '<iframe class="pagepreview-preview" src="' . base_path() . 'pagepreview/' . $preview_id . '"></iframe>';
$form_state['rebuild'] = TRUE;
}