I have a class MyData.php like this:
class myData {
function render() {
$view = new Zend_View();
$view->str = 'This is string.';
echo $view->render('myview.phtml');
}
}
and a myview.phtml file:
<div id='someid'><?= $this->str ?></div>
In another view I am doing something like this:
<?php
$obj = new myData ();
$obj->render(); // it should be <div id='someid'>This is string.</div>
?>
It is giving me following exception:
Message: no view script directory set; unable to determine location for view script
MyData.php and myview.phtml are in same directory.
I did it like this:
I changed my myview.phtml to myview.php
<div id='someid'><?= $this->str ?></div>In myData class render function:
And all things are working as I asked in question. I was missing
$view->setScriptPath($path);in my code.Help: