![]() |
MVC Question about site wide feature - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: MVC Question about site wide feature (/showthread.php?tid=5226) |
MVC Question about site wide feature - El Forum - 01-12-2008 [eluser]SethG[/eluser] Have an MVC question for you. Here's my scenario. I have a feature of an application called notes. I have a controller for notes and a model for notes. I have tried to build out notes as a feature that can be used related to multiple objects in the application and therefore would cross multiple controllers. For example I am creating notes for projects, notes for organizations, notes for people, .... So this leads to my question, I want to be able to display a list of notes and to do so by calling a simple function with parameters that explain what notes to display (for example passing an organization id). The function will return the html code to display the results. Currently I have done this in the model. I have a model function that not only queries for the data but generates and returns the html for display. Is this the wrong approach? Should I create a notes helper which takes the query array and generates the html? Hopefully this won't confuse but here is the code for what I have in the model ... again my question is should the code for formatting the results of a query for a feature such as this be better organized in a helper (or something else) instead of in the model? Code: function getNotesList($parentType = '', $parentID = '', $limit = '') { MVC Question about site wide feature - El Forum - 01-12-2008 [eluser]wiredesignz[/eluser] It's generally bad practice to have HTML created in your model, it would be better to create a partial View for that HTML snippet. MVC Question about site wide feature - El Forum - 01-12-2008 [eluser]SethG[/eluser] [quote author="wiredesignz" date="1200190852"]It's generally bad practice to have HTML created in your model, it would be better to create a partial View for that HTML snippet.[/quote] That makes perfect sense ... I think. It seems so simple I wonder why I missed that ... but that definitely happens. Thanks! |