winu
(Vinu Techintl)
April 30, 2014, 11:39am
1
Hi,
I have a Yii application with default controller AbcdController.php and it has a view abcd/dashboard.php. This view page is a dashboard which should show the output of four modules in my Yii application. I wish to get output from module’s controller action as
return $html = $this->renderInternal('index', array('data' => 'hi all'), true);
This code is in my module’s controller action.
But here problem is that I can’t access my module’s controller action from AbcdController. How can I call module’s controller action to get above $html? Is there any method to call module’s controller action?
jkofsky
(Jkofsky)
April 30, 2014, 6:09pm
2
winu:
Hi,
I have a Yii application with default controller AbcdController.php and it has a view abcd/dashboard.php. This view page is a dashboard which should show the output of four modules in my Yii application. I wish to get output from module’s controller action as
return $html = $this->renderInternal('index', array('data' => 'hi all'), true);
This code is in my module’s controller action.
But here problem is that I can’t access my module’s controller action from AbcdController. How can I call module’s controller action to get above $html? Is there any method to call module’s controller action?
Is renderInternal() a new option in Yii2? Never heard of it in Yii1.1.
Anyway: An idea would be to make a public variable that could be used to get the $html info. Actucally I might do:
class SomeController {
private $_html = null;
...
function getHtml() {
if is_null($_html) {
$_html = $this->renderPartial('index', array('data' => 'hi all'), true);
}
return $_html;
}
...
}
winu
(Vinu Techintl)
May 2, 2014, 3:39am
3
jkofsky:
Is renderInternal() a new option in Yii2? Never heard of it in Yii1.1.
Anyway: An idea would be to make a public variable that could be used to get the $html info. Actucally I might do:
class SomeController {
private $_html = null;
...
function getHtml() {
if is_null($_html) {
$_html = $this->renderPartial('index', array('data' => 'hi all'), true);
}
return $_html;
}
...
}
For renderInternal()
http://www.yiiframework.com/doc/api/1.1/CBaseController
I wish to get above code to be in my module and how can I call this function getHtml() form my core application controller?
jkofsky
(Jkofsky)
May 3, 2014, 5:11am
4
Maybe:
$x = application.moduleId.controllerId.getHtml();
winu
(Vinu Techintl)
May 6, 2014, 9:52am
5
Thanks… But its not working…
winu
(Vinu Techintl)
May 15, 2014, 10:43am
6
Create object of module’s controller in core application controller as
list($controller_obj) = Yii::app()->createController('module_controller_id');
$controller_obj -> init();
Now we can access our module controller using above object.
In module controller we should write functions to return view.
return $this->renderPartial('index', array('data' => 'hi all'), true);