Welcome Guest, Not a member yet? Register   Sign In
CI's equivalent to file_get_content?
#1

[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');
#2

[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);
#3

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




Theme © iAndrew 2016 - Forum software by © MyBB