joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.77k stars 3.65k forks source link

Retrive sitename in multilingual websites #35916

Closed mikajaxxx closed 3 years ago

mikajaxxx commented 3 years ago

Steps to reproduce the issue

go extension-> langauges- > content langauges & set site name in ' Custom Site Name ' try retrieve site name for language by: $app = JFactory::getApplication(); $site_name = $app->get('sitename'); or $config = JFactory::getConfig(); $site_name = $config->get( 'sitename' );

Expected result

both way render current language site name

Actual result

render default langauge site name

System information (as much as possible)

joomla 4.0.4

Additional comments

brianteeman commented 3 years ago

You must enable the language filter plugin

richard67 commented 3 years ago

@mikajaxxx Please check the previous comment and report back if your issue still persists after you have enabled the language filter plugin. Thanks in advance.

joomdonation commented 3 years ago

As pointed out by @brianteeman , you need to enable System - Language Filter plugin to have it works. The code which handles this could be found here https://github.com/joomla/joomla-cms/blob/4.0-dev/plugins/system/languagefilter/languagefilter.php#L189

Closing this issue as this is not a core issue.

mikajaxxx commented 3 years ago

@joomdonation & @brianteeman of course i enabled system - language Filter and System - Language Code before reporting this issue!

brianteeman commented 3 years ago

In which case neither of us can replicate the reported problem

brianteeman commented 3 years ago

image

image

image

image

image

mikajaxxx commented 3 years ago

It doesnt work on my website, i done it the same way as you! jeco

joomdonation commented 3 years ago

@mikajaxxx Where do you put your code?

mikajaxxx commented 3 years ago

@joomdonation at a system plugin

joomdonation commented 3 years ago

@mikajaxxx And that's the reason of the issue. If you look at https://github.com/joomla/joomla-cms/blob/4.0-dev/plugins/system/languagefilter/languagefilter.php#L189, you will see that the language filter plugin process that data on onAfterRoute event, so if your system plugin code is triggered before that, the data won't be available