Welcome Guest, Not a member yet? Register   Sign In
How to load data from a view file?
#11

[eluser]benners[/eluser]
I know how to load data from Controller to view as per your example. I'd prefer to do this but by calling the Model from the view I have just 3 lines of code. To add this rule to 40+ functions in my various Controllers and load in a Model everytime is going to take a lot more code so I can't see how this is sensible. I read something somewhere about using Plugins or similar in this situation but I have no experience of this.
#12

[eluser]TWP Marketing[/eluser]
[quote author="benners" date="1333695326"]I know how to load data from Controller to view as per your example. I'd prefer to do this but by calling the Model from the view I have just 3 lines of code. To add this rule to 40+ functions in my various Controllers and load in a Model everytime is going to take a lot more code so I can't see how this is sensible. I read something somewhere about using Plugins or similar in this situation but I have no experience of this.[/quote]

The nice thing about CI is that you can do this. I just don't recommend it. You are still loading the model to do database access, so there is no gain or loss. If your model is so large that you are concerned about load times and/or memory usage, then I recommend splitting that model into smaller versions and only loading what you need (in the controller). There are many ways to arrange your code and MVC is just one of those methods. The standard approach is to keep data manipulation out of the view.




Theme © iAndrew 2016 - Forum software by © MyBB