cannot modify header information - headers already sent

Permalink 1 user found helpful
I have a block I'm working on and within the controller.php I have a function that tries to modify the header information... ie...

header("Pragma: public");
header("Content-Type:.... etc etc..

Problem is I keep getting the "cannot modify header information - headers already sent" error message when I call the function...

is there any way round this in C5 ??

JimboJetset
 
ryan replied on at Permalink Reply
ryan
output your headers in a function named on_before_render() in your block's controller.

That may work..
JimboJetset replied on at Permalink Reply
JimboJetset
Thanks... I tried that but the error still persists... any other ideas...?
ryan replied on at Permalink Reply
ryan
What are you trying to do? Possibly a block controller isn't the right place to be outputting headers. Blocks are really intended to be pieces of content within a page..
jgarcia replied on at Permalink Best Answer Reply
jgarcia
JimboJetset replied on at Permalink Reply
JimboJetset
cheers.... I think I'm onto a winner with that one...
JimboJetset replied on at Permalink Reply
JimboJetset
well... the on_page_view() was indeed the right way to go however it has raised other obstacles lol... so my thanks to you both but jgarcia takes the credit.
Precificar replied on at Permalink Reply
Precificar
Sometimes you need to put JS or CSS file links on the header for a block to work. If it's something you're putting on a block and not on a theme, it's better to output this from the block. Makes it easier to share on the market and works better.