Welcome Guest, Not a member yet? Register   Sign In
Message: Undefined property
#11

[eluser]a.somervell[/eluser]
See there ya go, exactly what it neededSmile I was gonna ask that... why didnt I... *facepalm
#12

[eluser]xwero[/eluser]
I never use CI addable library code to global templates.
Code:
$data['error_string'] = '';
if(!$this->validation->run())
{
   $data['error_string'] = $this->validation->error_string;
}
// load view
This also moves the if out of the view file.
#13

[eluser]a.somervell[/eluser]
That also makes sense Smile
#14

[eluser]a.somervell[/eluser]
..but then i'd have to change my code everywhere Sad haha
#15

[eluser]wiredesignz[/eluser]
It's very important to keep $this type objects out of Vews as my friend xwero shows (and the CI tutorials incorrectly indicate) because your View is then dependent on those objects. View should be passed data or references to objects only.
#16

[eluser]xwero[/eluser]
i tend to use micro views for things like error messages
Code:
if(!$this->validation->run())
{
   $error['error_msg'] = $this->validation->error_string;
   $data['msg'] = $this->load->view('error_msg',$error,TRUE);
}
In most view files i have a $msg variable to show errors, success messages, ...
#17

[eluser]GSV Sleeper Service[/eluser]
[quote author="wiredesignz" date="1206546704"]It's very important to keep $this type objects out of Vews as my friend xwero shows (and the CI tutorials incorrectly indicate) because your View is then dependent on those objects. View should be passed data or references to objects only.[/quote]

interesting point. I am guilty of using
Code:
$this->load->view('header')
within views, but thinking about it I could probably get away with just using a normal php include
#18

[eluser]xwero[/eluser]
The loader library is a core library so it always is present. It is with the classes you have to load you need to be careful.
#19

[eluser]wiredesignz[/eluser]
I think its ok to use $this->load->view, because the loader is 100% always available in CI.

Personally I don't like to use include in top level code, it kind of defeats the point of using a framework.

EDIT:
xwero beat me again :lol:




Theme © iAndrew 2016 - Forum software by © MyBB