Jump to content

Help In Plugin Vars "$Logged_In" And The "$This->Base_Uri"


Recommended Posts

Posted

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

Posted

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.

Posted

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 :)

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...