Jump to content

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


PauloV

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...