[eluser]Bramme[/eluser]
Hey all,
I'm working on my second CI site, but it's rather big. It has a news and blog section, but both rely on the same database table (the only difference is the type: blog or news).
Now, at the moment, I use just one controller for my frontend, and I use routing to just cut off the class name.
My controller sorta looks like this
Code:
function index
$this->home()
function home
do stuff
function news
$this->_news('news')
function blog
$this->_news('blog')
function _news($type)
$this->db->where($type)
Now I think my news function is doing waaay too much:
- if no id is set, display all posts with pagination
- if an id is set, show the single post
- show the comments under a single post
- process comment posting
This makes for a rather lenghty function, it's about 200 lines (haven't put anything in models yet, so that'll shorten it a little) but I was wondering:
Is there a better approach to all of this? I know MVC doesn't necessarily dictate how to do this, but I'm just looking for some pointers from you old rots.
Should I create a separate controller for my news, or maybe a separate function for single items? Should I do the comment processing in another function?