简体   繁体   English

Drupal 6-加载其他内容而无需重定向

[英]Drupal 6 - load other content without a redirect

I have created a custom module that includes a hook_submit function. 我创建了一个包含hook_submit函数的自定义模块。 Is it possible to load another page/form at this point without having to do a redirect? 是否可以在此时加载另一个页面/表单而无需执行重定向?

The reason being within the logic of the submit function, there are variables I would like to pass through to another page, but it consists of complex data structures (objects, arrays etc) which would not be appropriate for post/get data. 原因是在Submit函数的逻辑内,有一些我想传递给另一个页面的变量,但是它由复杂的数据结构(对象,数组等)组成,不适用于发布/获取数据。

Thanks 谢谢

hook_submit() is the tail end of the chain of form processing. hook_submit()是表单处理链的尾端。 Once it has completed it's duties you have two options: redirect (either via drupal_goto() or by returning $form["#redirect']) to another page or do nothing, in which case the page you clicked the submit button on will be reloaded. 完成任务后,您有两个选择:重定向(通过drupal_goto()或通过返回$ form [“#redirect'])到另一页或不执行任何操作,在这种情况下,您单击了提交按钮的页面将重新加载。

You have several options for passing data on to your redirect destination, $_SESSION and the database being the most frequently used. 您可以使用几种选择将数据传递到重定向目标上,$ _SESSION和最常用的数据库。 You also have the option of setting complex data values in the Drupal.settings object in javascript, but in this instance that doesn't buy you much if your end goal is to parse that information via PHP. 您还可以选择在javascript的Drupal.settings对象中设置复杂的数据值,但是在这种情况下,如果最终目标是通过PHP解析该信息,那将不会给您带来多少好处。

Without specific information on what your end goal is it's hard to provide specific advice, however assuming using $_SESSION or the database as a cache isn't an option for you, you might consider looking into both core FAPI and ctools' respective implementations of multi-part forms for additional guidance. 如果没有关于最终目标的具体信息,很难提供具体的建议,但是,假设您无法选择使用$ _SESSION或将数据库用作缓存,则可以考虑同时研究核心FAPI和ctools各自的multi实现部分表格以获取其他指导。

In Drupal you can determine the path where the form will be submitted. 在Drupal中,您可以确定提交表单的路径。 For this you can use 为此,您可以使用

$form['#action'] = url("<another page>") ;

inside your form and after submit it will take you to the another page and still you will get all the post values from that form. 在表单中,提交后将带您进入另一个页面,您仍然将从该表单中获取所有帖子值。 Use $_POST['<element_name>'] for further post value retrieval. 使用$_POST['<element_name>']进一步获取帖子值。

Hope this will help. 希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM