PauloV Posted September 1, 2014 Report Posted September 1, 2014 Hello, What Im doing rong? class LiveChatPlugin extends Plugin { ... public function my_function() { if (!isset($nick->Record)) Loader::loadComponents($nick, array("Record")); $nick = new Record(); $nick = $nick->select(array("first_name","last_name"))->from("staff")->where("user_id", "=", $logged_in)->fetch(); $nick = $nick->{"first_name"}." ".$nick->{"last_name"}; $blc_include = file_get_contents(PLUGINDIR . DS . "live_chat" . DS . "views" . DS . "default" . DS . "admin_live_chat_count_include.pdt"); $blc_include = str_replace("{{base_uri}}", $this->base_uri, $blc_include); $blc_include = str_replace("{{nick}}", $nick, $blc_include); return $blc_include; } } I want to call the global var "$logged_in" and the "$this->base_uri" but in this class I cant call Thanks in advance, PV Quote
Blesta Addons Posted September 1, 2014 Report Posted September 1, 2014 you can replcae $loggd_id var with $this->staff_id $this->staff_id = $this->Session->read("blesta_staff_id"); about $this->base_uri is returning anydata ? print_r($this->base_uri); PauloV 1 Quote
Blesta Addons Posted September 2, 2014 Report Posted September 2, 2014 $this->base_uri and all the var related to PATH/URL is not working in the ____plugin.php file . wich file (model/helpers) we should load to make them working ? Quote
Cody Posted September 2, 2014 Report Posted September 2, 2014 base_uri is defined in AppController, so it's only available to controllers that extend AppController. Plugin classes are not controllers, so they don't have this variable set. Use WEBDIR constant to give you the installation path, and Configure::get("Route.admin") or Configure::get("Route.client") to give you the rest of the URI. PauloV 1 Quote
PauloV Posted September 2, 2014 Author Report Posted September 2, 2014 base_uri is defined in AppController, so it's only available to controllers that extend AppController. Plugin classes are not controllers, so they don't have this variable set. Use WEBDIR constant to give you the installation path, and Configure::get("Route.admin") or Configure::get("Route.client") to give you the rest of the URI. Thanks I alredy figure it out this morning I use this WEBDIR.Configure::get("Route.admin") to get the web route and this $GLOBALS['_SESSION']['blesta_staff_id'] to get the staff id inside the plugin In PDT files was easier to find out With Blesta 3.3 now we will be able to optimise a lote of the code and it will fix the issue of "find" and "replace" functions that we have in some plugins for core files 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.