[eluser]Yorick Peterse[/eluser]
While rebuilding my guestbook from scratch I figured out I wanted to enable users to use custom templates. The basic idea is very simple, load a main template file from the templates directory and pass some variables to it. The problem was that loading a view didn't work, as it's bound to a views directory. Loading a file seemed to work, but again there was a problem. In this case loading a view doesn't enable users to pass variables with it.
Because I don't need a complete template library, nor doe I need a custom one, I figured out it would be best to modify the Loader library. Making a seperate library for just 3 lines of code isn't something I consider worth doing.
I made a slight modification to the function for loading files, it works as a charm :
Libraries/Loader.php
Code:
function file($path,$vars = array(), $return = FALSE)
{
return $this->_ci_load(array('_ci_path' => $path, '_ci_vars' => $this->_ci_object_to_array($vars),'_ci_return' => $return));
}
And that's it, you can now load files with variables, just as you can load views with variables. I still wonder why this isn't enabled by default.