• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Requesting advice on how to handle a later-added "modified date" field

Hi all,

I have a table of documents that initially did not contain a "last modified" field - a bunch of these documents therefor have no value for the last modified field, and when the document is returned in a search or browse, the date given is Dec 31, 1969.

What I would like to do is take any documents that have a last modified value of less than 100 to show up as "Not been recently modified" and the others will say "Updated: Mon 01, 2000".

Now I'm wondering if I should do a helper, or if I should add a function to my model. Part of my other problem with adding it to the model is how I would then handle the check on the last_modified field. I can't seem to decipher where in my code flow the last modified data conversion should take place - but I guess once I figure that out, how do I then put it back into my $data['docs'] array in the appropriate place so the view handles it properly?

Thanks a lot in advance for any help given!

Personally, I would be putting together a helper as the "Not been recently modified" message is a custom message specific to your (online) application. If you were doing some kind of calculation to the date or something to that effect then that would probably more likely go in the model.

What helps me with these kind of questions is to ask myself this: If I was building an API for this application and allowing outside sources to access any part of my application (via XML-RPC for instance) what would I need to do (in the model) to "standardise" the data so they always get something they expect. IF they expect an integer, they get an integer. If they expect a particular date format, they get a particular date format etc, etc...

In essence, model's are the API to the data for my application. I hope that helps - I don't know if I explained that very well... Tongue

Put the data check in the model, not a helper.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.