Adam Posted April 2, 2017 Report Posted April 2, 2017 (edited) Hello, I was trying to register an action for my plugin so a widget will appear on the client dashboard (widget_client_home). What I found is that the URL can not contain any GET parameters as jQuery fails with the following via the browser. public function getActions() { return array( ... array( 'action' => 'widget_client_home', 'uri' => 'plugin/cerberus/client_tickets/index/?whole_widget=true', 'name' => Language::_('cerberus.widget.title', true), ), ... ); } Uncaught Error: Syntax error, unrecognized expression: #widget_container_plugin_cerberus_client_tickets_index_?test=blah at Function.ot.error (jquery.min.js:4) at gt (jquery.min.js:4) at kt (jquery.min.js:4) at Function.ot [as find] (jquery.min.js:4) at init.find (jquery.min.js:5) at init (jquery.min.js:4) at x (jquery.min.js:4) at Object.$.blestaRequest.widget_id [as success] (jquery-client-3.5.0.js:113) at l (jquery.min.js:4) at Object.fireWith [as resolveWith] (jquery.min.js:4) If you look in app/client_controller.php the issue is not specifically with the URL but rather the method used to generate the $key/unique identifier for the that widget. Knowing that, I figured we could just take the SHA1 hash of the URL as that would give us a unique string with no special character issues. It also reduces memory since the key is fixed length and not variable with the URL. diff --git a/app/client_controller.php b/app/client_controller.php index cdc1dbc..752793e 100644 --- a/app/client_controller.php +++ b/app/client_controller.php @@ -95,7 +95,7 @@ class ClientController extends AppController // Load widgets configured for display $plugin_actions = $this->PluginManager->getActions($this->company_id, $widget_location, true); foreach ($plugin_actions as $plugin) { - $key = str_replace('/', '_', trim($plugin->uri, '/')); + $key = sha1($plugin->uri); $widgets[$key] = [ 'uri'=>$this->base_uri . $plugin->uri ]; -Adam Edited April 3, 2017 by Adam added sample code for the getActions function Quote
Blesta Addons Posted April 3, 2017 Report Posted April 3, 2017 Not sure if this possible, but what i do normally is to the set request inside the widget itself . are you want to make sorting table by indexes or something similar ? Quote
Adam Posted April 3, 2017 Author Report Posted April 3, 2017 27 minutes ago, Blesta Addons said: Not sure if this possible, but what i do normally is to the set request inside the widget itself . are you want to make sorting table by indexes or something similar ? I could move away from using GET parameters and make it part of the route, etc. But I still think this is a bug in Blesta (or something they should document), hence the bug report and patch. Lets see what @Paul and folks say. -Adam Quote
activa Posted April 3, 2017 Report Posted April 3, 2017 make a look at the controller admin_clients.php in services() function and you can see the whole_widget param set via the renderifajaxwidget i think . Blesta Addons 1 Quote
Adam Posted May 23, 2017 Author Report Posted May 23, 2017 Any update on this from the Blesta staff? -Adam Quote
Adam Posted June 14, 2017 Author Report Posted June 14, 2017 On 5/23/2017 at 9:06 AM, Adam said: Any update on this from the Blesta staff? -Adam Should I open a ticket with Blesta instead of posting to community forums? Is my explanation unclear? -Adam Blesta Addons 1 Quote
Jono Posted August 4, 2017 Report Posted August 4, 2017 On 5/23/2017 at 9:06 AM, Adam said: Any update on this from the Blesta staff? -Adam CORE-2439 Blesta Addons 1 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.