CodeIgniter Forums
Views and PHP Code - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Views and PHP Code (/showthread.php?tid=15337)

Pages: 1 2


Views and PHP Code - El Forum - 02-01-2009

[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


Views and PHP Code - El Forum - 02-01-2009

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