Puts Scripts and CSS in Initial request from internal requets
I have a main page(controller_welcome => C_W), and another controllers; these extends from Controller_DefaultTemplatre(C_DT). In C_DT i have a function called addScripts() and addCss() these adds to url of the javascripts files and Css respectly to the View template, and getScripts() this last function get the array of the Scrips added by the current controller.
In C_W I have an action that calls anothers controllers via Request::factory("KONTROLLER/AKTION"); and puts all in the current template request.
/* content of the C_W */
$params = array(); $controller1_request = Request::factory("controller1/index"); $controller1_response = $controller1_request->execute(); $params["extra"] .= $controller1_response->body();
$controller2_request = Request::factory("controller2/index"); $controller2_response = $controller2_request->execute开发者_StackOverflow中文版(); $params["extra"] .= $funny_response->body();
$this->template->content = View::factory("welcome/index", $params);
My question is: How I can add Scripts to the C_W Template from the Request::factory("controller1/index");
?
Static vars?
For example, rewrite your addScripts()
and addCss()
to work with a static properties, so you can call it from any instance of C_DT. Of course, those methods must be static.
Or create special static class (helper) for it.
精彩评论