3

The documentation for J3 instructs using Factory::getApplication('site') to get the site application, however according to the documentation for J4 doesn't have those method parameters anymore.

I'm working on a plugin that requires some file from my site template and aside from a database query, how can I get that template name? Is there a Factory::getSiteApplication() or anything?

1
  • 1
    Do you need this functionality to work in backend?
    – Sharky
    Sep 12, 2021 at 13:57

3 Answers 3

3

To specifically call the site application, you can use:

Factory::getContainer()->get(\Joomla\CMS\Application\SiteApplication::class);

In Joomla 4, getApplication() will always return the global application object and doesn't take any arguments.

1
1

The Joomla 4 core com_content component uses Factory::getApplication()->isClient('site');

See: https://github.com/joomla/joomla-cms/blob/4.0-dev/administrator/components/com_content/src/Extension/ContentComponent.php line 137

1
  • That's only to check if isClient('site') has little to do with my question.
    – thednp
    Sep 12, 2021 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.