CodeIgniter Forums

Full Version: Views and PHP Code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2

El Forum

[eluser]felyx[/eluser]
[quote author="Colin Williams" date="1233569738"]... or you can loop from the controller, calling a view on each iteration, and send the result to the view. ...[/quote]

I am not really familiar with this solution can you give me an example of how you do this please? I always loop in my views when it comes to display data since I am fine with looping in views.. Smile

El Forum

[eluser]Colin Williams[/eluser]
Code:
$data['blog_posts'] = $this->blog->get_recent();
$data['posts'] = '';
foreach ($data['blog_posts'] as $post)
{
   $data['posts'] .= $this->load->view('blog/post_teaser', array('post' => $post), TRUE);
}
$this->load->view('blog/recent', $data);
Pages: 1 2