Sreejith Sasidharan
Sreejith Sasidharan

Reputation: 1378

How to disable the theme output from a Drupal module?

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 ?

Upvotes: 0

Views: 679

Answers (3)

Dave Reid
Dave Reid

Reputation: 1270

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

Upvotes: 0

Pierre Buyle
Pierre Buyle

Reputation: 4873

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().

Upvotes: 1

GrayB
GrayB

Reputation: 539

Have you tried using the drupal API for this? See: http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_set_header/6

Upvotes: 2

Related Questions