class MyClass extends Smarty - filemtime() fails

33 views
Skip to first unread message

kherge

unread,
Nov 23, 2009, 7:12:30 PM11/23/09
to Smarty Developers
I'm extending the Smarty class and altering the way the fetch() method
retrieves templates.

The only alteration I make is to the cache_dir, compile_dir,
template_dir, and append a file extension to the template name.

public function fetch ( $a,
$b = null,
$c = null,
$d = null )
{
if ( $this->_root_dir === null )
$this->_root_dir = $this->template_dir;

$this->cache_dir = self::$TEMP
. $this->design
. MyClass::$DS
. 'cache'
. MyClass::$DS;

$this->compile_dir = self::$TEMP
. $this->design
. MyClass::$DS
. 'compile'
. MyClass::$DS;

$this->template_dir = $this->_root_dir
. $this->design
. MyClass::$DS;

$a .= self::EXT;

return parent::fetch( $a, $b, $c, $d );
}

When I use this in conjunction with a custom page block:

public function _platform_page ( $params, $content )
{
$old = $this->design;

if ( ! empty( $params['design'] ) )
$this->design = $params['design'];

$content = $this->fetch( 'header' )
. $content
. $this->fetch( 'footer' );
$this->design = $old;

return( $content );
}

The header fails to load with the following error message:

filemtime() [<a href='function.filemtime'>function.filemtime</a>]:
stat failed for .\templates\header.tpl

Uwe.Tews

unread,
Nov 24, 2009, 12:48:49 PM11/24/09
to Smarty Developers
I could not reproduce this problem.

Do you have some more details on the error message like line number
and call stack?

Which version of Smarty didyou use?
Reply all
Reply to author
Forward
0 new messages