3

You have to promise not to giggle, but my situation is following:

Instead of using partials and helpers and other similar tools that we use already, we want to use a custom view outside all frames and borders of the actual application. Basically, we need at this point to load clean HTML into a variable upon a certain reaction a model. That is monkeys business and can be done by virtually anyone without using a keyboard.

The problem is that the HTML pages that we want to create are supposed to be quite extensive and are a trainwreck to debug/maintain/expand due to the inate "return $arrlglllgll;" approach. To make a smooth and humane script, we would very much love to use the .phtml style with clean html mixed up with php injections without actually rendering it.

Is that possible and how?

I am currently struggling with

$mailView = new Zend_View();
$mailView->setScriptPath('/Templates');
echo($mailView->render('test.php'));
die;

Where test.php is a file I have been trying to reach with any means and corelations imaginable, but ultimately failed every time due to

 exception 'Zend_View_Exception' with message 'script 'test.php' not found in path (\library\Extras\Controller\Action\Helpers\)' in \library\Zend\View\Abstract.php:875
Stack trace: blablabla

Loading a custom view from a controller is butt-easy, just provide the relative path and you're set, but it seems that I cannot find anything if I shoot from within a library. Any advice?

4

1 回答 1

2

万一有人想知道,这比我想象的要容易得多......

// Set the view
$layout = new Zend_Layout();
$view = $layout->getView();

// Send inherited custom parameters
$view->params = $params;

因此,您可以将 $view 用作真实视图并根据需要加载任何 $view->helper。

要保存渲染视图,请键入...

$savingParameter = $view->render('controller/subfolder/' . $page . '.phtml');

泰达

于 2009-09-07T14:25:05.107 回答