So, I have a actions.class.php and have the function like that:
public function executeGetHTML($request)
{
$pageName = $request->getParameter('name', '');
}
I do not want to output the content of getHTMLSuccess.php
instead, depending on the request, I need to get the HTML code of another page (without processing it ..e.g. filtering it..etc). Actually, the page content will be output in JSONP within a JSON variable. e.g.
For example, I call /getHTML?name=abc
and abc.html (or abc.php) has the content:
<div>Hello, my beautiful world</div>
then I will get the page content of Hello, my beautiful world
and output it as: mycallback({content:'Hello, my beautiful world'});
I know I can do file_get_content(...) but it sounds like very heavy to do file read explicitly while symfony should already cache and know .
include / require won't work in this... so, is there a light-weight way to do it?
You could try the getPresentationFor method (http://www.symfony-project.org/api/1_4/sfController#method_getpresentationfor)
public function executeGetHTML($request) {
$pageName = $request->getParameter('name', '');
$html = $this->getPresentationFor('module', 'action');
}
This will return the output for the requested module/action rather than outputing it to screen
Didnt work for me in symfony 1.4.14, until I used getController():
$html = $this->getController()->getPresentationFor('module', 'action');
And also to pass parameters to the action:
$this->getRequest()->setParameter('parameter_name', value);
Another way to pass parameters:
$html = $this->getController()->getPresentationFor('module', 'action?id=123');