Welcome Guest, Not a member yet? Register   Sign In
Where to put build table rows HTML?
#1

I'm new to CI and the MVC-Pattern, so i wonder where to put what. If i understand right, Controllers are primarilly used for routing the requests and stick results together for delivery and view should only contain static content.

In my application i would show the table by using a static part from the view, where all the HTM init-stuff is done (loading bootstrap css and stuff). Also there is the heading of the table.

I've create a model to access my data, which works fine so far.

Now i wonder where to read from database and transform the results into HTML-Tags. Should it be done in controller or in view?
Should i code it inside the view? I guess this would break the concept of separating business-logic and content... ir should it do it inside the controller?
Reply
#2

@hacksler,

Have you tried the CI documentation? It has a good tutorial that can assist you in learning the MVC pattern: https://codeigniter.com/user_guide/tutorial/index.html
Reply
#3

Input        --> Processing --> Output 
Controller --> Model         --> View

SEE:  The Model-View-Controller (MVC) Design Pattern for PHP
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

(06-25-2018, 04:41 AM)hacksler Wrote: ...

Now i wonder where to read from database and transform the results into HTML-Tags. Should it be done in controller or in view?
Should i code it inside the view? I guess this would break the concept of separating business-logic and content... ir should it do it inside the controller?

You should not write much code in your view. It should just contain html and print statements and loops and if statements that directly outputs the presentation. 

In your controller you create whatever models you need and pass the data into the view where its rendered.
Simpler is always better
Reply




Theme © iAndrew 2016 - Forum software by © MyBB