Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template subfolder #147

Open
ghost opened this issue Apr 1, 2014 · 1 comment
Open

Template subfolder #147

ghost opened this issue Apr 1, 2014 · 1 comment

Comments

@ghost
Copy link

ghost commented Apr 1, 2014

I can't load a template in a subfolder.

When I use this:

  $rainTpl->draw("work/overview");

It does this

  C:\wamp\www\ravenproj/storage/themes/minimal/overview.html

but when changing to

  $rainTpl->draw("work\overview");

then it works.. but how can I let it work with forward slashes

  C:\wamp\www\ravenproj/storage/themes/minimal/work\overview.html
@WebInac
Copy link

WebInac commented Jun 2, 2014

I just fixed it for my project,
Here is my solution:

protected function _check_template( $template ){
// set filename
$template_name = basename( $template );

    $template_basedir           = dirname($template)== '.' ?null: dirname($template) . '/';
    $template_directory         = (strpos($template,"//")=== false&&strpos($template,":\\")=== false)?static::$conf['tpl_dir'] . $template_basedir:$template_basedir;
    $template_filepath          = $template_directory . $template_name . '.' . static::$conf['tpl_ext'];
    $parsed_template_filepath   = static::$conf['cache_dir'] . $template_name . "." . md5( $template_directory . serialize( static::$conf['checksum'] ) ) . '.rtpl.php';

    // if the template doesn't exsist throw an error
    if( !file_exists( $template_filepath ) ){
        $e = new RainTpl_NotFoundException( 'Template '. $template_name .' not found!' );
        throw $e->setTemplateFile($template_filepath);
    }

    // Compile the template if the original has been updated
    if( static::$conf['debug']  ||  !file_exists( $parsed_template_filepath )  ||  ( filemtime($parsed_template_filepath) < filemtime( $template_filepath ) ) )
        $this->_compile_file( $template_name, $template_basedir, $template_filepath, $parsed_template_filepath );

    return $parsed_template_filepath;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant