CodeIgniter Forums
CI's equivalent to file_get_content? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: CI's equivalent to file_get_content? (/showthread.php?tid=26582)



CI's equivalent to file_get_content? - El Forum - 01-18-2010

[eluser]dsentker[/eluser]
Hello,

i've got this view (very simplified, of course Smile ) :

Code:
<html>
<head><?php echo $title; ?></head>
<body>
<?php echo $content; ?>
</body>
</html>

In the Controller, i would normally use this to fill this view:

Code:
$data['title'] = 'Hello World!';
$data['content'] = '<h1>Good Morning!</h1><p>Hello World!</p>';
$this->load->view('viewfile');

But what if i want to assign a view-file to the $data-array? Disregard the Syntax, like that:
Code:
&lt;!-- contentfile.php: --&gt;
<h1>Good Morning!</h1>
<p>Hello World!</p>

Code:
$data['title'] = 'Hello World!';
$data['content'] = this->view('contentfile');
$this->load->view('viewfile');



CI's equivalent to file_get_content? - El Forum - 01-18-2010

[eluser]rogierb[/eluser]
It's all in the userguide: Returning views as data

Code:
$data['title'] = 'Hello World!';
$data['content'] = this->load->view('contentfile', null, true);

$this->load->view('viewfile', $data);



CI's equivalent to file_get_content? - El Forum - 01-18-2010

[eluser]dsentker[/eluser]
Sorry, you're right. I missed the last paragraph in the Userguide "Views". Thanks for that.