![]() |
Is it okay to leave a controller without a view? - 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: Is it okay to leave a controller without a view? (/showthread.php?tid=22932) |
Is it okay to leave a controller without a view? - El Forum - 09-24-2009 [eluser]rvillalon[/eluser] I have a controller for error logging and is accessible by the browser. For example, I can access it and log an error by going to: http://www.mywebsite.com/error/save/access_key/error_id/addtl_details The last three parameters are used as follows: access_key : i match this in my config file to make thwart unwanted requests error_id : unique id to store addtl_details : additional error description Once it validates the information, I save into a database but I don't have any "VIEW" set up. It simply returns a blank page. Is this okay? Also, does anyone have any tips on how I might improve this? Is it okay to leave a controller without a view? - El Forum - 09-24-2009 [eluser]davidbehler[/eluser] You call this controller using AJAX? Or what exactly do you do? If you call it using AJAX, then it's fine if it does only return a blank page, no ones gonna see it anyway. You don't have to use a view file, but as soon as you want to display content it's appropriate to do so, as a bunch of echo commands are pretty ugly xD Is it okay to leave a controller without a view? - El Forum - 09-24-2009 [eluser]rvillalon[/eluser] Thanks, waldmeister! Also, what do you think of passing the access_key through flash? I included it to prevent unauthorized use of my error logger, but I think it can easily be sniffed for since it's coming from client-side. Any thoughts? Is it okay to leave a controller without a view? - El Forum - 09-24-2009 [eluser]rvillalon[/eluser] Come to think about it, here's a better approach: Dynamically return file types through CI. This way, error logging can happen server-side. For example, http://www.mywebsite.com/request/xml/file_name would return an XML file Whereas, http://www.mywebsite.com/request/image/file_name returns an image file. I could do this by making use of Header. ie: Header('Content-type: image/png'); If there's an issue loading the file, I can log the error then. LOL Sorry for not thinking ahead! |