2

my Joomla have 3 language and I submit sitename for each language in language manager. I used this to get sitename

$app = JFactory::getApplication(); $sitename = $app->getCfg('sitename');

but this code only give me sitename submitted on General Configuration. how to get sitename in that language?

MJH
  • 653
  • 2
  • 14
  • 36

3 Answers3

0

Try this,

In your case $sitename = $app->getCfg('sitename'); will not work bcoz you are using multi-language Joomla Site.

This option is only for get the values from global configuration.

You can try this, You have multiple language files available each have a Proper site name consider the constant is SITE_NAME="Your site name";

Then you can simply get your site name like below.

JText::_('SITE_NAME');

Hope its helps..

Jobin
  • 8,238
  • 1
  • 33
  • 52
0

Another possible solution (tho not so elegant is to fetch it from database table #__languages, where sitename is stored):

$lang = JFactory::getLanguage();
$db   = JFactory::getDBO();

$query = 'SELECT sitename FROM #__languages WHERE lang_code = "' . $lang->getTag() . '"';
$db->setQuery($query);

$sitename = $db->loadResult();
// If no sitename defined - show default sitename
if (!$sitename){
    $app = JFactory::getApplication();
    $sitename = $app->getCfg('sitename');
}
di3sel
  • 2,002
  • 15
  • 24
0

This is an old post but I wanted to reply because the same process I will outline below is applicable in Joomla 2.5 as well as Joomla 3.x. It does not require any special editing or extensions.

This can easily be accomplished by using Joomla's built in features in the "Language manager". These steps also assume you already have a Multilingual Joomla site up and running. If you need instructions on how to do this you can refer to this link:
https://www.scribd.com/doc/82768844/Joomla-2-5-multi-language-website-without-using-3rd-extensions-in-10-steps
then use the steps outlined below to give your site a custom site name for each language. The Link above is for Joomla 2.5 but the same steps outlined there can be applied to a Joomla 3.x site.

1) Log in to the administrator section of the site

2) Click on "Extensions"

3) From the Extensions dropdown menu choose "Language Manager"

4) Once in Language Manager you will see the installed languages and these options:
Installed - Site
Installed - Administrator
Content
Overrides

NOTE:
In Joomla 2.5 they will be listed in a row above the installed languages.
In Joomla 3.x they will be listed in a column to the left of the installed languages.

5) Now click on "Content"

6) The name of each language under the "Title" row will now be clickable. Click on the name of the language you want to set the "Custom Site Name" for.

7) Once you have clicked on the language name look for "Site Name". In Joomla 2.5 this will be on the right hand side. In Joomla 3.x this will be in a row above the options.

8) Once you click on Site Name you will see an option that reads "Custom Site Name". Enter the custom site name for that language and it will take priority, essentially overriding what is entered in the Global Configuration.

Please note also that you only need to enter a custom site name for the language that you want to change it for. Example: if your site's main language is English and you have the English version of your site name listed in the Global Configuration and you also have French, Spanish, and German installed then you only need to enter, if you want, a custom site name for the French, Spanish, and German languages.

Something else to consider is that if you need to add a custom site name for the language(s) you more than likely should consider adding custom Metadata for the language(s) such as the "Meta Keywords" and "Meta Description". To accomplish this follow the steps outlined above up to Step 5. Instead of clicking on Site Name you would click on Metadata and enter the language specific customized information for "Meta Keywords" and "Meta Description".

9) Last but not least, and most importantly, after you're all done with the language customizations, Click on "Save" or "Save & Close" to save all your changes.

This new language specific custom site name will be displayed if the site is offline.

Also, for SEO purposes, you can have your site name displayed either before or after the name of the Menu item which appears in the tabs. That setting can be changed in the Global Configuration options. Under SEO Settings look for "Include Site Name in Page Titles" and choose either "After", Before, or "No".