如何禁用 Drupal 模块的主题输出?

发布于 2024-10-08 04:09:01 字数 284 浏览 0 评论 0原文

我有一个模块,其中列出了网站中时事通讯订阅者的电子邮件地址。我想将这些电子邮件 ID 保存为 CSV。但以下代码给出了标头已发送错误,因为我不知道如何从模块中禁用主题。

header("Content-Type: application/octet-streamn"); 
header("Content-Disposition:attachment;filename=$file");
readfile($tmpdir.$file);

有什么建议吗?

I have a module which list the email address of the newsletter subscribers in website.I want to save those email id as CSV. but the following code gives a header already sent error because i don't know how to disable the theme from the module.

header("Content-Type: application/octet-streamn"); 
header("Content-Disposition:attachment;filename=$file");
readfile($tmpdir.$file);

any suggestions ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

喵星人汪星人 2024-10-15 04:09:01

您是否尝试过使用 drupal API 来实现此目的?请参阅:http://api.drupal.org/ api/drupal/includes--common.inc/function/drupal_set_header/6

鹿港巷口少年归 2024-10-15 04:09:01

如果您需要从 Drupal 输出非主题和/或非 html,则必须从模块中执行。在页面处理程序中打印输出而不是返回它。例如,请参见 blogapi_rsd()

If you need to output non-themed and/or non-html from Drupal, you will have to do it from a module. In your page handler print your output instead of returning it. See for instance blogapi_rsd().

冰雪之触 2024-10-15 04:09:01

确保使用退出;这样执行就会停止,Drupal 就没有机会尝试提供其输出。

Make sure to use exit; so that execution will stop and Drupal doesn't get a chance to try and provide it's output.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文