• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Understanding View Cells

#1
Hello everyone!

I'm working on my first project on code igniter and found it quite promising so far. I've been going through the docs and came across View Cells, which seemed quite useful on the first glance. But after going through the entire documentation I found it a bit contradicting to the MVC pattern. 

On one hand, we are supposed to make calls to Views and Models only from a Controller class, but View Cells on the other hand, suggests that the method can be called from any class- even outside Controller. The doc mentioned an example that uses a function from a different class(not controller), querying data from a model and feeding the retrieved data to a view. Is it a good practice? Doesn't this approach break the MVC pattern? If someone could help clarify, it'd be really helpful. Cheers.
Reply

#2
The recommended way of using view cells is to place them into a Library.

The view cell methods in the Library can then interact with the model etc;
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
(02-28-2021, 01:48 AM)InsiteFX Wrote: The recommended way of using view cells is to place them into a Library.

The view cell methods in the Library can then interact with the model etc;
Hey, thanks for responding. I take it that it is alright to interact with models even from outside controllers.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.