Welcome Guest, Not a member yet? Register   Sign In
Calling a function from inside a view
#4

[eluser]Ayeyermaw[/eluser]
Not sure what example would suit you best but one of my applications needs a list of students for a dropdown in more than one occasion and in more than one view. The function dropdown() is in my student_model
I created a helper - "students_helper.php" and in there I have the following code:

Code:
function dd_students()
{
  global $CI;
  return $CI->student_model->dropdown('id','name'); // Returns an array

}


I can call on this function from the controller or the view (need to make sure the helper is loaded either automatically or in the controller ofc).
To make it more complex I could add parameters to the function which I can pass in from the view or the controller.
Its not the best example but I hope it helps.

// EDIT: I didn't show the student_model loaded but hope you understood that would need to happen at some point too




Messages In This Thread
Calling a function from inside a view - by El Forum - 04-27-2012, 02:18 AM
Calling a function from inside a view - by El Forum - 04-27-2012, 03:42 AM
Calling a function from inside a view - by El Forum - 04-27-2012, 03:51 AM
Calling a function from inside a view - by El Forum - 04-27-2012, 04:15 AM
Calling a function from inside a view - by El Forum - 04-27-2012, 04:31 AM
Calling a function from inside a view - by El Forum - 04-27-2012, 05:12 AM
Calling a function from inside a view - by El Forum - 04-27-2012, 06:26 AM
Calling a function from inside a view - by El Forum - 04-27-2012, 07:08 AM
Calling a function from inside a view - by El Forum - 04-27-2012, 07:20 AM
Calling a function from inside a view - by El Forum - 04-27-2012, 03:18 PM
Calling a function from inside a view - by El Forum - 04-30-2012, 02:24 AM
Calling a function from inside a view - by El Forum - 05-02-2012, 12:44 AM
Calling a function from inside a view - by El Forum - 05-07-2012, 01:48 PM
Calling a function from inside a view - by El Forum - 05-08-2012, 01:45 AM
Calling a function from inside a view - by El Forum - 05-08-2012, 03:53 AM
Calling a function from inside a view - by El Forum - 05-08-2012, 06:53 AM
Calling a function from inside a view - by El Forum - 05-08-2012, 07:41 AM
Calling a function from inside a view - by El Forum - 05-08-2012, 08:03 AM
Calling a function from inside a view - by El Forum - 05-08-2012, 08:45 AM
Calling a function from inside a view - by El Forum - 05-08-2012, 08:54 AM
Calling a function from inside a view - by El Forum - 05-08-2012, 09:11 AM
Calling a function from inside a view - by El Forum - 05-08-2012, 09:14 AM
Calling a function from inside a view - by El Forum - 05-08-2012, 09:22 AM
Calling a function from inside a view - by El Forum - 05-08-2012, 03:43 PM
Calling a function from inside a view - by El Forum - 05-09-2012, 12:52 AM
Calling a function from inside a view - by El Forum - 05-09-2012, 07:55 AM
Calling a function from inside a view - by El Forum - 05-09-2012, 09:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB