I am trying to make a function that I can call as follows,
view( 'archive', 'post.php' );
and what the function really does is.
include( 'view/archive/post.php' );
The reason for this is that in the future I will distribute the directory, which will be view/archive/another_level/post.php
. I don't want to go back everywhere in my code and change all the included paths.
This is currently what I have for my function, except that it seems that include is a call inside the function and not 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 include the file correctly?
EDIT:
There were no errors. Thanks to @Ramesh for the error checking code, ini_set('display_errors','On')
, I was able to see that other “non-displayable” errors were detected in the included file, which seemed to cause the file to not be displayed ...
source share