Welcome Guest, Not a member yet? Register   Sign In
Multiple Views ?!?!
#1

[eluser]Unknown[/eluser]
Hello World,

Sorry my bad english...

Why CI don't work with multiples views in the controller ?? Only load the last view...

How do solution to this limitation ??

Wait Answer...

Thanks...
#2

[eluser]gunter[/eluser]
user guide: loader class

Code:
$this->load->view('file_name', $data, true/false)

The third optional parameter lets you change the behavior of the function so that it returns data as a string rather than sending it to your browser. This can be useful if you want to process the data in some way. If you set the parameter to true (boolean) it will return data. The default behavior is false, which sends it to your browser. Remember to assign it to a variable if you want the data returned:

that means, you have to set the last parameter to TRUE! then you can echo multiple views..
echo $this->load->view('myfile', '', true);
echo $this->load->view('myfile2', '', true);
#3

[eluser]kylehase[/eluser]
Enabling the third parameter pulls the strings from the buffer. Will this affect performance? Would it be better to simply append new output data to the buffer then have some function to print the buffer?

From Loader.php
Code:
ob_start();

                // If the PHP installation does not support short tags we'll
                // do a little string replacement, changing the short tags
                // to standard PHP echo statements.

                if ((bool) @ini_get('short_open_tag') === FALSE AND config_item('rewrite_short_tags') == TRUE)
                {
                        echo eval('?>'.preg_replace("/;*\s*\?>/", "; ?>", str_replace('<?=', '<?php echo ', file_get_contents($path))).'<?php ');
                }
                else
                {
                        include($path);
                }

                log_message('debug', 'File loaded: '.$path);

                // Return the file data if requested

                /*-------- THIS SECTION IS RUN IF THE THIRD PARAMETER IS TRUE ----
                 * Notice that the buffer is cleared and returned  */

                if ($return === TRUE)  
                {
                        $buffer = ob_get_contents();
                        @ob_end_clean();
                        return $buffer;
                }

Notice the section :
Code:
if ($return === TRUE)
The output is buffered while in the Loader but is released if you set the third parameter to true.




Theme © iAndrew 2016 - Forum software by © MyBB