views:

80

answers:

1

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?

+1  A: 

In case anybody wonders, this is a lot easier than I ever thought it to be...

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

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

You can thus use the $view as a real view and load any $view->helper as you please.

To save rendered view, type...

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

TADAA

John