如何禁用 Drupal 模块的主题输出?
我有一个模块,其中列出了网站中时事通讯订阅者的电子邮件地址。我想将这些电子邮件 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否尝试过使用 drupal API 来实现此目的?请参阅:http://api.drupal.org/ api/drupal/includes--common.inc/function/drupal_set_header/6
Have you tried using the drupal API for this? See: http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_set_header/6
如果您需要从 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()
.确保使用退出;这样执行就会停止,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.