![]() |
Code Question - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Code Question (/showthread.php?tid=65503) |
Code Question - wolfgang1983 - 06-20-2016 Hello, I have a model function that I have been working on every thing seems to be working fine I would like to no should I make a if statement for my return base_url() at the bottom of page. If so what would you recommend? PHP Code: <?php RE: Code Question - PaulD - 06-20-2016 Hi, You should check it has been set before generating a URL with it. I would have made this into a helper. If called I would return simply either TRUE or FALSE if resized image was created. I would also have put the location of the image either as a config item, or an option in the method. Within this helper I would also have another function called something like 'show_image', which checks that the image exists, and returns a url to it. But, not the base_url bit, that part is for the view to add. If it did not exist, it could then call the function above to create the image as a private function. I also always follow the naming convention of adding _model, _view, _helper to the end of my class names. So your model here would be Image_resize_model.php However, that is all opinion, as naming conventions are not enforced, and the beauty of CI is you can do it however you want. Good job though, Paul. |