Welcome Guest, Not a member yet? Register   Sign In
Move code from controller to helpers/models
#2

(This post was last modified: 01-27-2016, 12:47 PM by cartalot.)

i don't fully understand what you are trying to do - but the first thing you probably want to do is "separate the concerns".
in other words if you are showing products, then you have the concern of getting the products from a db table or some other data source.
which products, what products, what fields to return, etc etc So - Get the Products - that is one concern, and its very appropriate
for that to happen in a Model. Very Important - if no products come back - then that is dealt with in the Controller.
In other words you are not checking if there are products in your View files.

The second concern - which should be completely separate - is how the Products will be displayed in the View or
Show the Products. the key there is to create a data structure where its then very easy to show the products in the View with
the minimum amount of logic in the View file. Where that stage is done is a personal choice but my suggestion is to use a Model
because its the easiest.
Reply


Messages In This Thread
RE: Move code from controller to helpers/models - by cartalot - 01-27-2016, 12:47 PM



Theme © iAndrew 2016 - Forum software by © MyBB