Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Lucas Krause
19,924 PointsDoes `get_list_view_html()` really belong to the Model code?
In this video Randy introduces the concept of views.
I just wondered whether the get_list_view_html() function does really belong to the model code file it is correctly placed in.
I think in a more complex MVC structure, with separated controller code, and view code that is included in multiple places (by the controller), that function would be be better placed in the view code, or am I wrong?
I'm really new to that MVC approach. Thanks for any answer. :)
P.S. Why can't I post a question regarding a video any more, though I still can post a question regarding a quiz or a code challenge? Is that a new feature here at Treehouse?
EDIT
Randy is addressing exactly that issue in a later video. He points out that it is actually view code.
1 Answer
Tom Nulty
2,017 PointsHi Lucas,
Yes actually I would have to agree with you. In a more advanced system I would separate the function from the products.php and create a new productsview.php file and include that too, since it does belong in a view because its function is purely on how to display the products on the page. But the reason I think they are not doing this is because they seem to only want one file to be associated with the products to keep it simple.
Good spot! :)
P.S. I'm not sure about including a video in a forum post, I am still yet to try that. But I have seen it done recently.
Tom.
Lucas Krause
19,924 PointsLucas Krause
19,924 PointsThanks for your answer, Tom. :)
P.S. Seems as if including a video is available again today :D
Lucas Krause
19,924 PointsLucas Krause
19,924 PointsI have another question addressing MVC. Maybe you can answer that, too. :D