Blesta Addons Posted November 6, 2014 Report Posted November 6, 2014 is there any methode/tip , to make a plugin controller or my_plugin_controller.php set a var and use it globbaly in the system , so i can access it via structure.pdt or client_main.pdt ..ect ? Quote
Tyson Posted November 6, 2014 Report Posted November 6, 2014 You can set data to the structure with $this->structure->set("var", "value"); as long as your plugin controller is extending AppController. Plugins are loaded after the client_main template has been displayed, so you wouldn't be able to set data there. Quote
Blesta Addons Posted November 6, 2014 Author Report Posted November 6, 2014 thanks i will try this . is only the client_main template is loaded before Plugins ? Quote
Tyson Posted November 7, 2014 Report Posted November 7, 2014 I assume you've setup a widget on the Client Main page (ticket widget?), and all of those widgets are loaded from that page via AJAX. Other locations where the plugin is not directly accessed, depending on events, are loaded in the same way. Quote
Blesta Addons Posted November 7, 2014 Author Report Posted November 7, 2014 Hello Tyson , this question has nothing related to my support plugin , is related to a internal plugin , this plugin has a normal render without any ajax . Quote
activa Posted December 21, 2015 Report Posted December 21, 2015 related to this question , we want to set a var via plugin to use it in structure.pdt . is possible ? we have tried to sue the preaction event to set the var , but is not working . how to achieve this ? Quote
Tyson Posted December 21, 2015 Report Posted December 21, 2015 related to this question , we want to set a var via plugin to use it in structure.pdt . is possible ? Yes. we have tried to sue the preaction event to set the var , but is not working . What have you done? how to achieve this ? Your plugin controller: class MyController extends MyPluginController { public function preAction() { parent::preAction(); $this->structure->set('my_var', 'my_value'); ... } ... } structure.pdt: echo $this->Html->ifSet($my_var); The variable will only be displayed in the structure if your plugin controller has been loaded. Quote
activa Posted December 21, 2015 Report Posted December 21, 2015 [/code]The variable will only be displayed in the structure if your plugin controller has been loaded.this is our probleme . we need to use this var in any other controller like the base_uri var .i have tested all this in the preAction event without result $this->my_test ="kkkk" ; $this->structure->my_test = "4654564"; $this->view->my_test = "31313"; $this->structure->set("my_test", "46789"); $this->set("my_test", "kkkk"); Quote
Tyson Posted December 22, 2015 Report Posted December 22, 2015 The variable you set is not available on pages where the plugin is not loaded to call one of its controller actions. Your plugin is simply not called on most pages, so it never sets the variable to the structure. Have you tried tying into the Appcontroller.structure event? Quote
activa Posted December 22, 2015 Report Posted December 22, 2015 The variable you set is not available on pages where the plugin is not loaded to call one of its controller actions. Your plugin is simply not called on most pages, so it never sets the variable to the structure. Have you tried tying into the Appcontroller.structure event? the structure event will inject a html code in the header or the body . what i want is to inject a var (string or array) to the structure . let say i want my plugin to collect some data from database and send it as a var to use is globally in my structure . and normally the preAction event is called in all the pages loaded ? why is not setting the vars ? Quote
Tyson Posted December 22, 2015 Report Posted December 22, 2015 Have you tried setting the event to return an array of key/value pairs, where the key is the variable name, and the value is the variable's value? Quote
activa Posted December 22, 2015 Report Posted December 22, 2015 Have you tried setting the event to return an array of key/value pairs, where the key is the variable name, and the value is the variable's value? no , i will try it now . Quote
activa Posted December 22, 2015 Report Posted December 22, 2015 Have you tried setting the event to return an array of key/value pairs, where the key is the variable name, and the value is the variable's value? no success , i have tried . return array ("my_test" => "126" ); it would be wonderfull if the preAction can send return vars to the structure.pdt . this feature can help alot of developpers/designer to add a smarty ideas to blesta . Quote
Tyson Posted December 23, 2015 Report Posted December 23, 2015 It looks like you should be able to set variables to the structure from the Appcontroller.structure event, although I neither wrote the event nor tested this behavior. What are you setting for your event exactly? Quote
activa Posted December 23, 2015 Report Posted December 23, 2015 It looks like you should be able to set variables to the structure from the Appcontroller.structure event, although I neither wrote the event nor tested this behavior. What are you setting for your event exactly? the Appcontroller.structure event is just sent a output (html/javascripts) to the structure . no way to set a var for using in the template . the Appcontroller.preAction event is called before any other controller , so it can be adjusted to set var for using in template structure.pdt . i appreciate your effort and help if you can test them and give me the final result, so if not possible is not worth to lose time in something that can't be handled now by blesta . just to explain what i want to do . let say i want to collect total invoices (open, closed, draft) in a var array() , then i want to send this var to the structure.pdt to use it in the header or any place . can this be achieved via Appcontroller.structure event or Appcontroller.preaction event ? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.