![]() |
Checking if a file exists - 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: Checking if a file exists (/showthread.php?tid=32278) |
Checking if a file exists - El Forum - 07-18-2010 [eluser]Jacob Krustchinsky[/eluser] Hello, Im trying to create a simple template system that works as follows. Within the views folder there are two sub-directories labeled, themes and templates. The themes houses a header.tpl and footer.tpl as well as the theme specific styles and graphics. The templates houses a default set of view templates in correspondence with their appropriate controllers. When I go to render a template I simply call $this->template->render($template_name, $data); . Now the issues is, I want to check if a file exists in the theme folder with the template_name, if so render that file otherwise render the one in the default set. How can I check if the file_exists in the themes folder from within a library class? I cant use file exists and fopen returns an error. Any help? Checking if a file exists - El Forum - 07-18-2010 [eluser]KingSkippus[/eluser] Why can't you use file_exists()? In your controller, you can do this: Code: if (file_exists(APPPATH.'views/themes/'.$filename)) { Note that there's no $ in front of APPPATH and no slash after it, it is a constant that points to your application directory. |