Page 1 of 1
Suggestion - renderAction?
#1
Posted 15 April 2010 - 06:11 AM
MVC and Ruby already have renderAction() method, but yii not yet... maybe it's time?
-
-
Thanks, you make me stronger!
-Thanks, you make me stronger!
#3
Posted 15 April 2010 - 07:38 AM
Quote
One of the upcoming new features being added to ASP.NET MVC 2 Beta is a little helper method called Html.RenderAction and its counterpart, Html.Action. This has been a part of our ASP.NET MVC Futures library for a while, but is now being added to the core product.
Both of these methods allow you to call into an action method from a view and output the results of the action in place within the view. The difference between the two is that Html.RenderAction will render the result directly to the Response (which is more efficient if the action returns a large amount of HTML) whereas Html.Action returns a string with the result.
Both of these methods allow you to call into an action method from a view and output the results of the action in place within the view. The difference between the two is that Html.RenderAction will render the result directly to the Response (which is more efficient if the action returns a large amount of HTML) whereas Html.Action returns a string with the result.
Check this LINK and this LINK
-
-
Thanks, you make me stronger!
-Thanks, you make me stronger!
#4
Posted 15 April 2010 - 12:29 PM
I suppose same as Cake requestAction and ZF has something like that.. mostly there is talk how bad they are because use so many resources.. but i agree its pretty usefull in many cases where coding a widget is just double work.
#5
Posted 15 April 2010 - 12:38 PM
It runs a controller action, captures the output and then displays?
#6
Posted 17 April 2010 - 09:35 AM
Y!!, on 15 April 2010 - 12:38 PM, said:
It runs a controller action, captures the output and then displays?
That/s write it does the same thing:
Consider an example where in I want to render some UI based on some business logic as a partial within parent UI.
I needed this feature in my current portion of application I am developing. Basically I am rendering a page, while rendering a page, in one of the div I need to load list of folder so I just created a partial load_folder and tried using $this->renderPartial('load_folders'), but then I realized that load_folders should be an action so that it can go to DB and fetch folder information from table.
I am stuck here, trying to find some good solution to avoid violating MVC design. Anyone got suggestion?
#7
Posted 17 April 2010 - 11:24 AM
I'm not test this piece of my code, but maybe something like:
class Controller extends CController {
private $_isChildAction=false;
/**
* @return boolean
*/
public function getIsChildAction(){
return $this->_isChildAction;
}
/**
* @param boolean $value
*/
public function setIsChildAction($value){
$this->_isChildAction=$value;
}
/**
* @param string $actionID
* @param string $controllerID
* @param string $return
* @return null|string
*/
public function renderAction($actionID,$controllerID,$return=false){
if(!strcasecmp($controllerID,$this->getId())){
if(null!==($action=$this->createAction($actionID))){
if(($parent=$this->getModule())===null)
$parent=Yii::app();
ob_start();
if($parent->beforeControllerAction($this,$action)){
$this->runActionWithFilters($action,$this->filters());
$parent->afterControllerAction($this,$action);
}
$output=ob_get_clean();
if($return)
return $output;
else
echo $output;
}
else
$this->missingAction($actionID);
}
else if(null!==($ca=Yii::app()->createController($controllerID.'/'.$actionID))){
list($controller,$actionID)=$ca;
$controller->init();
$controller->setIsChildAction(true);
return $controller->renderAction($actionID,$controllerID,$return);
}
else
$this->missingAction($actionID);
}
}
-
-
Thanks, you make me stronger!
-Thanks, you make me stronger!
#8
Posted 17 April 2010 - 11:56 AM
Is it no option to simply wrap $this->forward($controller, false)?
Share this topic:
Page 1 of 1

Help















