Wednesday, August 1, 2012

Codeigniter php frameworks: views part 3


Codeigniter php frameworks will be start to views part 3, if you haven’t read the previouspart, please read it before. In part 3, we will be teaching you about Storing Views within Sub-folders and Adding Dynamic Data to the view. Firstly is Storing Views within Sub-folders, your view files can also be stored within sub-folders if you prefer that type of organization. When doing so you will need to include the folder name loading the view, like this $this->load->view('folder_name/file_name');.

Now let’s change our learning to Adding Dynamic Data to the View. Data is passed from the controller to the view by way of an array or an object in the second parameter of the view loading function. Codeigniter php frameworks have example using an array. So you can copy it to your controller file with your text editor.

using array variables.
using object variables.

FYI, if you use an object, the class variables will be returned into array elements. We will show you the code if you have and controller, open it and use this code. Codeigniter php frameworks.


After that open your view file and change the text to variables that correspond to the array keys in your data, this is the code.


And now you can try it. Okay I think enough for this part 3 of views, we will see you in the next part. Stay at Codeigniter php frameworks. Keep shipping!!!

This post of Codeigniter php frameworks: views part 3 is references from http://codeigniter.com/user_guide/general/views.html.