Skip to content

Commit

Permalink
Enabled the loading of views using extensions other than .php. This i…
Browse files Browse the repository at this point in the history
…s useful for including .phtml files for example
  • Loading branch information
Sam de Freyssinet committed Feb 19, 2010
1 parent 6242a05 commit a080bc5
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion classes/kohana/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,21 @@ public function __toString()
*/
public function set_filename($file)
{
if (($path = Kohana::find_file('views', $file)) === FALSE)
// Detect if there was a file extension
$_file = explode('.', $file);

// If there are several components
if (count($_file) > 1)
{
// Take the extension
$ext = array_pop($_file);
$file = implode('.', $_file);
}
// Otherwise set the extension to the standard
else
$ext = ltrim(EXT, '.');

if (($path = Kohana::find_file('views', $file, $ext)) === FALSE)
{
throw new Kohana_View_Exception('The requested view :file could not be found', array(
':file' => $file,
Expand Down

0 comments on commit a080bc5

Please sign in to comment.