Im trying to make a function that I can call as follows,
view( 'archive', 'post.php' );
and what the function really does is this.
include( 'view/archive/post.php' );
The reason for this is if in the future I expand the directory to be view/archive/another_level/post.php I dont want to have to go back everywhere in my code and change all the include paths.
Currently this is what i have for my function, except it appears that the include is being call inside the function, and not being called when the function is called...
function view( $view, $file )
{
switch ( $view )
{
case 'archive' : $view = 'archive/temp'; break;
case 'single' : $view = 'single'; break;
}
include( TEMPLATEPATH . "/view/{$view}/{$file}" );
}
How can I get this function to properly include the file?
EDIT:
There were no errors being displayed. Thanks to @Ramesh for the error checking code, ini_set('display_errors','On') I was able to see that there were other 'un-displayed' errors on the included file, which appeared to have caused the file not to show up...