CodeIgniter Forums
basic understanding - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: basic understanding (/showthread.php?tid=40639)



basic understanding - El Forum - 04-14-2011

[eluser]artisa[/eluser]
hi,

recent i had a situation where i was generation a list of data in "view", nothing special.
but then i was wondering how should i show status, like:
1 - open
2 - close
3 - error

Code:
//views/cool_stuff/list.php
...
echo '<td>'.$item->status.'</td>';
...

but, as you may guess status 1,2 and 3 doesn't look cool enough.

so, first thought was to make array, like:
Code:
$super_status = array('1'=>'Open','2'=>'close','3'=>'Error');

and then i got confused, where should i put this array. Some other views might be interested into these status titles as well.

So, whats the best practice?


basic understanding - El Forum - 04-14-2011

[eluser]Unknown[/eluser]
be aware about your health


basic understanding - El Forum - 04-14-2011

[eluser]artisa[/eluser]
[quote author="frank.william62" date="1302814518"]be aware about your health[/quote]

any useful suggestion?


basic understanding - El Forum - 04-14-2011

[eluser]danmontgomery[/eluser]
Config file, language file, in the model, stored in the database... Could put it in several places. If you're storing status as an integer, I would probably store the values in the database, so you could join the status table in your query and not have to worry about converting in the view.


basic understanding - El Forum - 04-15-2011

[eluser]artisa[/eluser]
language file seems to the good place. Model file sounds logic too, but how to access to model file from view?