注册Drupal菜单路径?

时间:2010-05-10 18:00:26

标签: drupal drupal-6 drupal-routes

如果我正在创建一个模块,并希望有两个自定义路径:

path / path / path / index.htm(调用drupal_get_form)

并发布到

路径/路径/路径/ result.htm

你是怎么做到的?我在第二条路上得到404。我很容易得到第一条路径的形式和我想要的东西。我想做的就是将表格作为drupal表格的主题并在此处显示。

2 个答案:

答案 0 :(得分:1)

这看起来不错:http://drupal.org/node/290462

<?php
/**
* 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;
    }
  }
}
?>

答案 1 :(得分:0)

知道了。实施AHAH以及所有这些。在我的回调中忘记了一个参数。