2010-12-14 40 views
0

我试图在drupal 6.19中重定向'用户名/密码'页面后提交到'改变位置',然后用户页面。drupal 6.19密码重置重定向

我正在使用的主题挂钩来获得预处理功能和它,我编辑$变量:

$variables['form']['#action'] = 'alter location'; 

,之后我用drupal_render()。

在drupal调试我发现#action被设置为'alter location',但在 html标签中,我仍然看到action ='user/password',并且它不会将我重定向到所需的位置。

在此先感谢

+0

我不确定它,但看看你是否可以改变'$ variables ['form'] ['redirect'] ='改变位置';' – acm 2010-12-14 10:39:58

回答

0

在Drupal的工作方式是这样的:用户请求包含表单的页面。一个函数创建一个结构化数组,构成该表单。该数组在主题图层中呈现。如果用户提交表单,Drupal会调用相同的例程以再次构建结构化数组。但现在它被用来验证和处理用户输入。如果处理例程返回路径或设置了?destination#redirect,则Drupal会执行内部重定向。如果不是,则再次显示相同的表单。然后只有你的代码在主题层执行。但是要注入#redirect才会迟到。 Drupal不会再看它了。

更改#action是没有意义的,因为用户输入发送到Drupal的菜单系统翻译并调用不期望和处理输入的例程的URL。

尝试path redirect模块。如果不起作用,请按照这些instructions to create a custom module

0

谢谢!!!

我通过期运用解决它 - > hook_form_FORM_ID_alter功能像.... mymodulename_form_FORM_ID_alter

因为在这里看到link text

这是我做过什么,它做的工作对我来说:

功能mymodulename_form_FORM_ID_alter(& $ form){ $ form ['#action'] ='alter_location'; }

1

由于这个comment

/** 
* Implementation of hook_form_alter(). 
*/ 
function jm_form_alter(&$form, $form_state, $form_id) { 
    if (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id) { 
    $form['buttons']['submit']['#submit'][] = 'jm_redirect_handler'; 
    } 
} 

/** 
* Attaches the redirect to the submitted form. 
* 
* @param unknown_type $form 
* @param unknown_type $form_state 
* @return unknown 
*/ 
function jm_redirect_handler($form, &$form_state) { 
    if ($form_state['nid']) { 
    // reloading as I do not know the node type context. You probably do not need to :), just set the redirect using $form_state['nid'] 
    $node = node_load(array('nid' => $form_state['nid'])); 
    switch($node->type) { 
     case 'project': 
     $form_state['redirect'] = 'projects/'. $node->nid; 
    } 
    } 
} 

我发现解决方案的工作原理。