[eluser]meridimus[/eluser]
Hi there,
I'm working on a personal project, learning the codeigniter framework for future projects. I'm using a traditional MVC approach to my application design.
I'm having a slight difficulty working out where to manipulate data correctly when calling from a database, for example:
* My model is calling a news post
* That data gets passed to my controller
* Which then gets injected to my view where I loop the result -
Code:
<?php foreach($posts->result() as $post): ?>
<!-- HTML -->
<?php endforeach; ?>
If I wanted to manipulate for example, the date of every news post to be "1 day ago" instead of the standard mysql date formatting, where should I do the manipulation? I know I could use the date helper to convert to mysql_to_unix(), then the timespan() but I'd rather not do this manipulation in the view (because this is just an example, I'd like to do more manipulation than this, most likely in the controller).
Because I'm currently passing information into the view, is there a way I can intercept this in the controller without adding too much overhead? What's the best method?