Get the default language in the site frontend of joomla 2.5 - joomla

How do I get the default language in the site frontend of Joomla 2.5?

After hours of reading through web and sources, I found this would be the correct answer:
JComponentHelper::getParams('com_languages')->get('site')

Try this
$lang =& JFactory::getLanguage();
echo 'Current language is: ' . $lang->getName();
http://docs.joomla.org/JFactory/getLanguage
For more details Click here

To get the users language on Joomla 3 you can do
JFactory::getUser()->getParam('language', JFactory::getLanguage()->getTag());

Related

how to give the url in joomla supporting form

I’m new to joomla and I’m using joomla 2.5. I need to redirect the page in joomla to another page. I saw that JROUTE is used for giving urls in joomla. but it start only from joomla folder. I need to get a file in the path
http://localhost/joomla/images/uploads/file.pdf
how can I write the above URL in joomla standard format?? can I use JURI base with jroute ??
Try this,
echo JURI::root().'images/uploads/file.pdf'
JURI::root() will return the site url.
If you required physical path try JPATH_SITE
Hope it helps..

get Joomla sitename in different language

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?
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');
}
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..
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".

How to get Joomla installed domain

I need to do custom redirect after login, but i'm not very familiar with the base of Joomla, so i'm did a little hardcode
$app->redirect(JRoute::_('http://'.$_SERVER['HTTP_HOST'].substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/')).'/index.php?option=com_myapp'));
But in some cases there are problems, so is it possible somehow determinate what is the default joomla domain/url/path where it is installed so i could use something like $domain.'/index.php?option=com_myapp'?
P.S.
Using 2.5
You can get the joomla site url using-
JURI::base();
JURI::root();
JURI::base() Result differs according to front and backend
You can check different joomla constant here-
http://docs.joomla.org/Constants
This answer may also be helpful-
Change Redirect URL of Joomla Login Page

Load page title in joomla 2.5 content

I am looking for a way to load a page title in the Joomla 2.5 content for SEO purposes. I know in joomla you can use a function to load a module such as {loadposition box1}.
Is there a way to have a feature or does anyone know an extension so you can do something similar to this {loadpagetitle}.
This will save me hours of work.
Thanks.
Firstly, install the Direct PHP plugin and enable it.
Then copy and paste the following code into your article:
<?php
$mydoc = JFactory::getDocument();
$mytitle = $mydoc->getTitle();
echo $mytitle;
?>
Make sure you use the php tags though.
Hope this helps. Regards.

Codeigniter internationalization library how to save user's language choice

I am using this multilanguage addon http://codeigniter.com/wiki/CodeIgniter_2.1_internationalization_i18n to make available my codeigniter sites in various idioms.
I have this php code with echo links to change the language
echo anchor($this->lang->switch_uri('en'),'English | ');
echo anchor($this->lang->switch_uri('es'),'Español | ');
echo anchor($this->lang->switch_uri('ro'),'Română');
It does the change with no problem, but it doesn't remember it. When I change page, from home to about, will go back to browser's language or Romanian if browser's language is not defined.
So, what could go wrong? What and how should I do to remember that choice?
You could simply change the choice by using the session:
$this->session->set_userdata('language', 'en');
See more details about using session data
Later refer to what the users choice is by calling:
$language = $this->session->userdata('language ');

Resources