I am writing a utility method that makes an API call to get data, then populating a view file w/ that data:
// decode API response
$response = json_decode($sa->response);
// pass data to view
$this->view->paf = $response->response;
// NEED TO GET HTML HERE INSTEAD OF DISPLAYING VIEW
$this->_helper->layout->setLayout('print-nosubmit');
What actually happens is that the response is decoded and the view (‘print-nosubmit’) is then displayed w/ the data in $response. That is all well and good EXCEPT I do not want to display the view. I still need to get the view populated w/ the data but it is only to get the HTML (not just the html from ‘print-nosubmit’ but the html from that file AFTER it gets the data) to pass along to DOMPDF for PDF creation. I am (obviously) going about this the wrong way since I don’t actually want to load the layout but I don’t know of a good way to get the data in $response to that view and then only get back the raw HTML.
I am sure there is an approach I can take to accomplish this task but I need a pointer in the right direction.
Thanks!
* Update: Just to make things more clear, ‘print-nosubmit’ is a VIEW file and is located in /views/scripts/print-nosubmit.phtml.
After trying just about everything I could think of I found a solution:
I now have the entire HTML contents of what print-nosubmit.phtml generates after it is rendered w/ the data stored in $html.
Huzzah!