Using $this when not in object context in Templates Problem

26 views
Skip to first unread message

rs324

unread,
Jun 30, 2010, 9:42:25 AM6/30/10
to Symfony Components
i just used the sample and i cant use this

my index file :

<?php

define('ROOT',dirname(__FILE__));

require_once ROOT.'/sftpl/sfTemplateAutoloader.php';
sfTemplateAutoloader::register();


$loader = new sfTemplateLoaderFilesystem(ROOT.'/templates/%name
%.php');

$engine = new sfTemplateEngine($loader, array('php' => new
sfTemplateRendererPhp()));

echo $engine->render('index2', array('name' => 'Fabien'));

?>

and my template files :

index2.php :
======================
<?php $this->extend('layout') ?>


<?php $this->set('title', 'My Page Title') ?>


<h1>My Webpage</h1>

Hello <?php echo $name ?>



======================

layout.php :
====================
<html>
<head>
<title><?php $this->output('title') ?></title>
</head>
<body>
<?php $this->output('content') ?>
</body>
</html>
======================

now when showing index.php its dosent event know the $this var so its
mean he dont think he in class

its the core base

what is worng ?

Aleksey Denysyuk

unread,
Jul 1, 2010, 12:22:18 PM7/1/10
to Symfony Components
Try not to specify explicitly render engine for php. I used it like
that:
$engine = new sfTemplateEngine($loader);

Regards,
Aleksey
Reply all
Reply to author
Forward
0 new messages