(07-29-2015, 01:32 PM)Wouter60 Wrote: Quote:(5) The 5th is difficult to understand. - The next thing to do is passing this data to the views. - I assume the code is to be pasted into News.php
You're right: the index() method is part of the News controller.
It collects the news items via the model.
It stores the data in an array called $data.
Then, it passes this array to the views that are loaded:
PHP Code:
$this->load->view('news/index', $data);
The first parameter for loading the view is the view file itself. In this case application/views/news/index.php.
The second parameter is an array containing all the variables that you want to pass to the view. In this case $data.
The view will automatically extract the array. So, when your controller defines an array element $data['news'], the view can simply process a variable $news. Which - in this case - is an array itself, containing one or more records. That's why the view index.php has a foreach .... endforeach loop to display the text from all news items.
Are you getting the picture?
Thanks Wouter60, I'm grateful for your help. I'll need to study more to get the picture.