注册Drupal菜单路径?
-
25-09-2019 - |
题
如果我正在制作一个模块,并且想要有两个自定义路径:
路径/路径/路径/index.htm(调用drupal_get_form)
并发布到
路径/路径/路径/结果.htm
你是怎样做的?我在第二条道路上得到404。我很容易获得表格和想要的东西。我要做的就是将表单结果作为Drupal表主题,并在此处显示。
解决方案 2
知道了。实施了阿哈等等。在我的回调中忘记了一个参数。
其他提示
这看起来像是一个好赌注: 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;
}
}
}
?>
不隶属于 StackOverflow