Welcome Guest, Not a member yet? Register   Sign In
How to output from a variable instead of a file?
#1

[eluser]sceleski[/eluser]
I have HTML chunks concatenated into a variable.

How to output this without breaking order?

Using load->view doesn't work because it looks up for a file. If I just echo it, then other load-view calls will not be rendered in same order (echoing will go first), and header will break.
#2

[eluser]Kyle Johnson[/eluser]
My first thought would be to create a "direct_output" view that looks something like this;

views/direct_output.php
Code:
<?php
echo $html;
?>

You would then, in your controller have the following:
Code:
$data['html'] = "<div><div>Something</div></div>";
$this->load->view('direct_output',$data);

I hope this helps.

EDIT Disregard this suggestion, use Aken's (Output class' append_output() method). Silly me, I forget CodeIgniter has all these cool features already.
#3

[eluser]Aken[/eluser]
Unnecessary. Use the Output class's append_output() method.
#4

[eluser]sceleski[/eluser]
[quote author="Aken" date="1362710410"]Unnecessary. Use the Output class's append_output() method.[/quote]

Great, that was it, thanks!

But that trick that Kyle said was interesting :-)




Theme © iAndrew 2016 - Forum software by © MyBB