Redirect submit to a particular template node
Laurent_ - October 10, 2009 - 20:43
| Project: | Signup |
| Version: | 6.x-1.0-rc6 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Description
Hi,
Here is my use case : when user validates its signup, the signup node shall be displayed with a different node template. The purpose of that template is to display different information than the those displayed with the default template (e.g. 'Thanks you' or additional information I can set up with CCK).
I've created a custom.module for this along with its node-custom.tpl.php. All works fine except I can't acess the preprocessed $vars in the custom template. I have to call them through $node->...
What am I missing here ?
Thanks for your help
Laurent
<?php
function custom_form_alter(&$form, &$form_state, $form_id) {
// Redirect to the signup page and add a 'done' argument
if ($form['#id'] == 'signup-form') {
$form['#redirect'] = 'node/'.arg(1).'/done';
}
}
function custom_menu_alter(&$items) {
// Add callback to the redirect page
$items['node/%node/done'] = array(
'title' => t('Signup confirmation'),
'page callback' => 'signup_confirmation',
'page arguments' => array(1),
'access callback' => 'node_access',
'access arguments' => array('view', 1),
'type' => MENU_CALLBACK,
);
function custom_theme() {
// Register module theme and its template
return array(
'node_signup_confirmation' => array(
'arguments' => array('node' => NULL),
'template' => 'node-custom',
),
);
}
function signup_confirmation($node) {
// Theme node with custom node template
$node = node_build_content($node);
$output = theme('node_signup_confirmation',$node);
return $output;
}
?>