Archive for September, 2010
Sonius Podcast – Mr Sonius’s Old Skool

MP3 320
1,the chimes,underestimate,1989
2,arrested development,tennessee,1992
3,shara nelson,uptight,1993
4,last night a dj saved my life,unknown,1995
5,remember me – sure is pure mix,blue boy,1997
6,bhagwan love example,sneak attack,1998
7,babylon,black dog feat ofra haza,1998
8,didi – arabian nightclub mix,khaled,1994
9,walk on the wld side,jamie j morgan,1990
10,say no go,de la soul,1989
11,the power rmx,snap,1989
12,old school new boy,omnivore,2000
13,telephone diconnect rmx,coldcut,1989
14,woodbeez,scritti politi,1984
How to get the returned value from a given module/action without rendering a view template. symfony 1.3
Posted by sonius in Programming, Symfony, Web Development on September 2, 2010
I had been tring to figure this out for a while now.
Typically if you wanted an action to render text, you would use the following line of code.
public function executeTest() {
return $this->renderText('abcdefg');
}
This is fine if you access that action directly.
I wanted a way to grab the output of another module/action.
The best way to this is using the getPresentationFor($module, $action) method
public function executeTest2(){
$output = sfContext::getInstance()->getController()->getPresentationFor('user', 'test');
echo $output;
exit;
}
The problem is…
This method grabs the presentation (ie, rendered template) for the module/action (‘user’, ‘test’) but in action executeTest, there is no template to render, causing an error.
Why dont I just create a template and be happy with the returned presentation? Id rather bypass this step to optimise code execution.
Normally I would return sfView::NONE in my action to fluff the template, but getPresentationFor() still looks for a template and I cant return any rendered text if Im returning sfView.
I found a way to set the view to NONE without returning sfView. This leaves me a way to return $this->renderText().
this is how I did it…
public function executeTest() {
sfContext::getInstance()->getController()->getRenderMode(sfView::NONE);
return $this->renderText('abcdefg');
}
public function executeTest2(){
$output = sfContext::getInstance()->getController()->getPresentationFor('user', 'test');
echo $output;
exit;
}