RainTPL (in RainFramework)

21 views
Skip to first unread message

Gerben Jacobs

unread,
Mar 30, 2011, 11:20:27 AM3/30/11
to rainframework
This is actually a double question..

I stumbled upon RainTPL first, then I noticed you guys made an entire
framework. So I tried both.

1) I wanted to 'draw' several templates, this works good. I also
wanted to cache the lot, but this didn't go that well.
When the no-cache version was rendered, everything was okay. When the
cached version jumped in, all 3 files were showing the *entire*
template (header, footer, content) meaning I had "<html>" in my source
3 times.
When I opened the cached files, everything looked normal.. so I have
no idea where to look.

P.s. tmp_dir can't be set. It keeps going to 'tmp'. So it will become
"tmp/<your_template_folder_name>/your_cached_files.php" and I figured
that if you set the tmp_dir variable that it would become
"<your_set_temp_dir>/your_cached_files.php".

2) When I tried the framework, I also wanted to add caching to the
template system. I used the example in the User Guides but I get this
error:

Fatal error: Call to undefined method Raintpl_view::is_cached() in C:
\wamp\www\oop\full\1\rain\library\View.php on line 70

Do I need to import the newest version of RainTPL into the
RainFramework?

federico ulfo

unread,
Mar 30, 2011, 11:24:46 AM3/30/11
to rainfr...@googlegroups.com
This sounds as a bug, can you please send me your code so I can debug
it and fix it ASAP?
Thanks for reporting
Federico

Gerben Jacobs

unread,
Mar 31, 2011, 2:47:23 AM3/31/11
to rainframework
My controller is like this:

<?php

class Books_Controller extends Controller{

function index(){
$db = new DB;
$tpl = new View;
$view = 'books/view_books';

if (!$tpl->is_cached($view)) {
$tpl->assign('time', date("G:i:s"));

$books = $db->get_list( "SELECT * FROM books" );
$tpl->assign('books', $books);
}

$tpl->draw($view);

}

function ajax_index(){
$this->ajax_mode( true, true );
echo draw_msg( 'hei' );
}

}

?>

On 30 mrt, 17:24, federico ulfo <rainelemen...@gmail.com> wrote:
> This sounds as a bug, can you please send me your code so I can debug
> it and fix it ASAP?
> Thanks for reporting
> Federico
>

Rain

unread,
Mar 31, 2011, 5:34:02 AM3/31/11
to rainframework
Hi Gerben,

the error is into library/View/Raintpl_View.php at row 21

function is_cache ( $tpl ){


replace with:


function is_cached ( $tpl ){


You can also download the latest develop version on git:
https://github.com/rainphp/rainframework


Thanks for your report,
Federico

Gerben Jacobs

unread,
Mar 31, 2011, 7:06:14 AM3/31/11
to rainfr...@googlegroups.com
Are you changing the code? I can also just change my controller code.
There's no real difference between "is cache" and "is cached", they both imply that you get a boolean back.

2011/3/31 Rain <rainel...@gmail.com>

Federico Ulfo

unread,
Mar 31, 2011, 7:16:18 AM3/31/11
to rainfr...@googlegroups.com
The correct method name is: is_cached
View::is_cached()
Raintpl_View::is_cache()  must be correct to Raintpl_View::is_cached()

Thanks
Federico

2011/3/31 Gerben Jacobs <jacobs...@gmail.com>

Gerben Jacobs

unread,
Mar 31, 2011, 10:14:17 AM3/31/11
to rainframework
Alright. Fixed.. but..

It shows up good one time, but when it wants to fetch the cached
version, it cannot find the $html property.
Notice: Undefined property: Raintpl_view::$html in C:\wamp\www\oop\full
\1\rain\library\View\Raintpl_View.php on line 28

On 31 mrt, 13:16, Federico Ulfo <rainelemen...@gmail.com> wrote:
> The correct method name is: *is_cached*
> View::is_cached()
> Raintpl_View::is_cache()  must be correct to Raintpl_View::*is_cached*()
>
> Thanks
> Federico
>
> 2011/3/31 Gerben Jacobs <jacobs.ger...@gmail.com>
>
>
>
>
>
>
>
> > Are you changing the code? I can also just change my controller code.
> > There's no real difference between "is cache" and "is cached", they both
> > imply that you get a boolean back.
>
> > 2011/3/31 Rain <rainelemen...@gmail.com>

Federico Ulfo

unread,
Mar 31, 2011, 10:33:32 AM3/31/11
to rainfr...@googlegroups.com
at  row 28  replace with:
if( $return_string ) return $this->cache; else echo $this->cache;

here the correct Rain_View class:
https://github.com/rainphp/rainframework/blob/master/library/View/Raintpl_View.php

thanks,
Federico

2011/3/31 Gerben Jacobs <jacobs...@gmail.com>
Alright. Fixed.. but..
Reply all
Reply to author
Forward
0 new messages