Raintpl and Zend

324 views
Skip to first unread message

Walter456

unread,
Jun 15, 2012, 2:20:40 AM6/15/12
to raintpl
Hello!

I have tested the integration of Raintpl in the Zend Framework.
In addition I have the tutorial
http://www.raintpl.com/News/2011/02/17/Integrating-Rain-TPL-into-Zend/
related.
Unfortunately I get an error message:

'Fatal error: Uncaught exception' RainTpl_NotFoundException 'with
message' Template not found error '! in C: \ xampp \ htdocs \ blog1 \
library \ Zend \ Controller \ Plugin \ Broker.php on line 336 '

Who can help?

Yours sincerely,

Stephan

Federico Ulfo

unread,
Jun 15, 2012, 2:22:48 AM6/15/12
to rai...@googlegroups.com
Hey Stephan,
the error says that it can't find the template, have you configured the template folder correctly?
Also are you using it in Zend Framework 1, right? We didn't integrated RainTPL for ZF2.

Walter456

unread,
Jun 15, 2012, 5:58:34 AM6/15/12
to raintpl
Hello Federico!

I work with the version ZendFramework 1.10.x.
I am guided by the following example:
http://www.raintpl.com/News/2011/02/17/Integrating-Rain-TPL-into-Zend/


I modified the application.ini:
raintpl.tpl_dir = ". / tpl /"
raintpl.cache_dir = ". / cache /"
autoloader namespaces [] = 'Raintpl'

The template directory and the cache directory is
folder in the 'public'.

In the 'library' I have created a directory called 'Raintpl'.
In this directory contains the class 'Raintpl.php' and
'View.php'.

The class 'Raintpl' was rewritten
'class Raintpl_Raintpl{ ... } '.
The class 'View.php' was rewritten in
'class Raintpl_View{ ... }'

In the bootstrap I created a _initView.

protected function _initView () {
$options = $this->getOption('raintpl');
$raintpl = new Raintpl_View($options);

$viewRender =
Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
$viewRender->setView($raintpl);
$viewRender->setViewSuffix('html');
Zend_Controller_Action_HelperBroker::addHelper($viewRender);

return $viewRender;
}

In the class 'View' I have adapted the method __ construct(){ ... }.

public function __ construct ($ data) {
parent :: __construct ($ data);

$ this->_raintpl = new Raintpl_Raintpl();
Raintpl_Raintpl ::$tpl_dir = $ data ['tpl_dir'];
Raintpl_Raintpl ::$cache_dir = $ data ['cache_dir'];
}

In my project there is a controller.
http://myblog1/blog/index/index/

This controller handles the action 'index'

public function index action () {
$ model = new Blog_Model_Index ();
$ row = $ model-> start ();

$ this-> view-> assign ('test', 'ABC');
$ this-> view-> render ('Blog_Index_Index');
}

At the moment I see an empty output without an error message.

Where is the mistake?

Yours sincerely,

Stephan

federico ulfo

unread,
Jun 15, 2012, 6:04:56 AM6/15/12
to rai...@googlegroups.com
I'm sure is into the folders, I suggest to enter in
raintpl::check_template And add an echo to the template folder and
exit; right after to test the variables and understand where is the
template that is trying to load!

Once you verify that the folder are OK if still doesn't work we've to
investigate more in deep. As I remember the version of Zend we
integrate with Rain didn't have namespace, and the version you're
using have them, right?
So I assume you're using RainTPL 3, is that correct?

Walter456

unread,
Jun 15, 2012, 11:10:53 AM6/15/12
to raintpl
Hello Federico!

I work with Raintpl Version: 2.7.2.
I'm working with Zend 1.10.x without namespace.
The class name is 'Raintpl_Raintpl'.
The class is under
... / myProject / library / Raintpl / Raintpl.php

I've changed the options in the 'application.ini'.
The directories are located under .. / myProject / public /

application.ini:
raintpl.tpl_dir = "/ tpl /"
raintpl.cache_dir = "/ cache /"

In the class Raintpl_Raintpl in the method
function draw ($ tpl_name, $ RETURN_STRING = false) {

# 190 include $ this-> tpl ['compiled_filename'];

I think this is a mistake.
In the compiled file, this entry is:
<php if (class_exists ('raintpl')) {exit;}>

The new class name is 'Raintpl_Raintpl'!
# 197 file_put_contents ($ this-> tpl ['cache_filename'], '<php if
(class_exists (' Raintpl_Raintpl ')) {exit;}?> "$ Raintpl_contents.);

The class will Raintpl_Raintpl two times through.

Greetings Stephan

Walter456

unread,
Jun 15, 2012, 11:21:36 AM6/15/12
to raintpl
Hello Federico!

Here is the second test.
In the method 'public function check_template ($ tpl_name) {'
the following variables:

$ tpl_basename = 'Blog_Index_Index';
$ tpl_basedir = 0;
$ tpl_dir = "/ tpl /";
$ this-> tpl ['tpl_filename'] = '/ tpl / Blog_Index_Index.html';
temp_compiled_filename = '/ cache/Blog_Index_Index.
4d903f3b6e1fa270cb797617d2ff072a';
$ this-> tpl ['compiled_filename'] = '/ cache/Blog_Index_Index.
4d903f3b6e1fa270cb797617d2ff072a.rtpl.php';
$ this-> tpl ['cache_filename'] = '/ cache/Blog_Index_Index.
4d903f3b6e1fa270cb797617d2ff072a.s_.rtpl.php';

If the error in the variable $ this-> tpl ['tpl_filename'] = '/ tpl /
Blog_Index_Index.html';?

If the entry of the directories in the 'application.ini' wrong??


Greetings Stephan

Federico Ulfo

unread,
Jun 15, 2012, 1:51:54 PM6/15/12
to rai...@googlegroups.com
Hi Stephan,
well, the path it shouldn't start with / because in that way you're selecting the root of your file system, so
 / tpl/Blog_Index_Index.html 
it should be
tpl/Blog_Index_Index.html

Also is the path relative to where the main script is called, the one in the browser, for example if you have your script in htdocs/index.php, you should have your template in htdocs/tpl/Blog_Index_Index.html.

If you still have problem feel free to write or even to send the the entire code privately to me and I'll fix it for you.

Thanks
Federico




Greetings Stephan

Walter456

unread,
Jun 15, 2012, 2:07:07 PM6/15/12
to raintpl
Hello Federico !

Test 3 / 'last chance'

I have build a simple class under .../myProject/library/Raintpl/
Raintplhelp.php.

class Raintpl_Raintplhelp{

public static function getRainTpl(){
include_once('raintpl/rain.tpl.class.php');
RainTPL::$cache_dir = './cache/';
RainTPL::$tpl_dir = './tpl/';
$raintpl = new RainTPL();

return $raintpl;
}

}

In the same directory is the rain.tpl.class.php.

In the action of my controller is:

public function indexAction(){
$raintpl = Raintpl_Raintplhelp::getRainTpl();

$raintpl->assign('test', 'ABC');
$tpl = $raintpl->draw( "Blog_Index_Index", true );
$this->view->content = $tpl;
}

Here is my template under .../myProject/public/tpl/
Blog_Index_Index.html .

<h3 align="center" style="color: blue;">Testseite</h3>
{$test}

Here is my view under .../myProject/application/modules/blog/views/
scripts/index/index.phtml
<?php echo $this->content; ?>

I know it's a very bad way.

Your sincerly

Stephan


Walter456

unread,
Jun 15, 2012, 3:01:53 PM6/15/12
to raintpl
Hello !

Solved !!!!!!!!!!!!!!!!!

Here the application.ini:

raintpl.tpl_dir = "tpl/"
raintpl.cache_dir = "cache/"
----------------------------------------------

Here the Bootstrap.php

protected function _initView(){

include_once('Raintpl/Raintpl_View.php');
$options = $this->getOption('raintpl');
$view = new Raintpl_View($options);
$viewRender =
Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
$viewRender->setView($view);
$viewRender->setViewSuffix('html');
Zend_Controller_Action_HelperBroker::addHelper($viewRender);
return $view;

}
-----------------------------------------------------

Here the controller:
$this->view->assign('test', 123);
echo $this->view->render('Blog_Index_Index.html', true);
-------------------------------------------------------

The rain.tpl.class.php and the View.php under .../myProject/library/
Raintpl/...

If you come to Germany you have some free beer.
Tomorrow I'll test Subtemplate.

Your sincerly

Stephan

Federico Ulfo

unread,
Jun 15, 2012, 3:04:02 PM6/15/12
to rai...@googlegroups.com
Happy we solved the problem, and thanks, I always accept a good beer :)


Your sincerly

Stephan

tot...@yahoo.com

unread,
Aug 7, 2015, 8:58:06 AM8/7/15
to raintpl, in...@suppenterrine.de
I have a problem while trying to make cms with OOP_PHP with RainTPL

i get error

Warning: mkdir(): Permission denied in /var/www/html/cms/includes/core/raintpl.class.php on line 320

Fatal error: Uncaught exception 'RainTpl_NotFoundException' with message 'Template blog.html not found!' in /var/www/html/cms/includes/core/raintpl.class.php:270 Stack trace: #0 /var/www/html/cms/includes/core/raintpl.class.php(166): RainTPL->check_template('blog') #1 /var/www/html/cms/includes/controllers/ArticlesController.php(67): RainTPL->draw('blog.html') #2 /var/www/html/cms/articles.php(11): ArticlesController->Show() #3 {main} thrown in /var/www/html/cms/includes/core/raintpl.class.php on line 270 
Reply all
Reply to author
Forward
0 new messages