Plugin environment Topic is solved

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
apay1
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Mon Oct 03, 2022 4:15 pm

Plugin environment

Post by apay1 » Tue Oct 04, 2022 8:15 am

Hello everybody,

Maybe this is a basic question for most of you all, but I don't know how I can find the environment my plugin is runing in, I mean frontend or backend ?

Thank you for your help !
Antoine.

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2901
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Plugin environment

Post by SharkyKZ » Tue Oct 04, 2022 8:41 am

Use application's isClient() method https://api.joomla.org/cms-3/classes/Jo ... d_isClient

To access application's instance in plugin you can declare app class property:

Code: Select all

protected $app
And then use in the code:

Code: Select all

if ($this->app->isClient('site'))
{
	// Do some stuff in frontend.
}

apay1
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Mon Oct 03, 2022 4:15 pm

Re: Plugin environment

Post by apay1 » Tue Oct 04, 2022 3:39 pm

Hi SharkyKZ ! Thank you so much, it works fine, exactly what I was looking for !


Locked

Return to “Joomla! 3.x Coding”