Heretic121
OMG Member
- Joined
- Sep 24, 2010
- Messages
- 446
This is just going to be a quick thread explaining some of things that I've recently worked out about the function responseView.
You can use responseView in any function, but it is needed, as far as I can tell, when you use actionIndex in your ControllerPublic class. responseView returns as an object, which can be saved in a variable and returned later, or just returned straight away. So the if you called:
It would return:
It's always useful knowledge to know what functions return and well... now you know
Also, you know that array you can return? It's called "params". Well you can use that in your templates.
So if you was to call:
And you put this ...
... in your template named "test-template", then it'll display "Testing" in the new page, or area, you put.
Some useful tips to know. As always, if you have any questions let me know and I'll try to answer them the best I can.
You can use responseView in any function, but it is needed, as far as I can tell, when you use actionIndex in your ControllerPublic class. responseView returns as an object, which can be saved in a variable and returned later, or just returned straight away. So the if you called:
PHP:
$this->responseView("Test_ViewPublic_Index","test-template",array('testArray'=>''));
Code:
object(XenForo_ControllerResponse_View)#30 (6) { ["viewName"]=> string(28) "Test_ViewPublic_Index" ["templateName"]=> string(11) "test-template" ["params"]=> array(1) { ["testArray"]=> string(0) "" } ["subView"]=> NULL ["containerParams"]=> array(0) { } ["responseCode"]=> int(200) }
Also, you know that array you can return? It's called "params". Well you can use that in your templates.
So if you was to call:
PHP:
$this->responseView("Test_ControllerPublic_Index","test-template",array("testString"=>"Testing"));
Code:
<div>
{$testString}
</div>
Some useful tips to know. As always, if you have any questions let me know and I'll try to answer them the best I can.