How do you modify the Login Form in Joomla?

CrazyMPh picture CrazyMPh · Sep 1, 2011 · Viewed 24.8k times · Source

I was wondering how can you change the text on the Joomla Login Form. For example:

From Username to Usr, from Password to Pwd, and other text also.

Maybe this question has been asked before but I couldn't find anything.

Does anyone know how to do this?

Answer

KingJackaL picture KingJackaL · Sep 6, 2011

You could do this with a template override, but that won't gracefully handle changes to the template from an upgrade, and you it assumes putting the new strings directly in the template - which won't allow multi-language easily.

The correct way to do this is (as alluded by adjamaflip), through language files.

The main login page for Joomla is through the 'com_users' component, although there is also the 'mod_login' module mentioned by hbit. This process will work for both, they'll just have slightly different files and strings to override (you'll probably want to override both).

If you look at the templates for any component or module, you'll see they have code sections like so:

<?php echo JText::_('MOD_LOGIN_VALUE_USERNAME') ?>
<?php echo JText::_('COM_USERS_LOGIN_USERNAME_LABEL') ?>

This is basically saying 'insert the translated text for WHATEVERSTRING here'. This translated text is stored in the appropriate language file, which will be in '/language/LANG/LANG.com_users.ini' for the 'com_users' component, etc. LANG by default is 'en-GB', so probably for you in '/language/en-GB/en-GB.com_users.ini' you'll find a line like:

COM_USERS_LOGIN_USERNAME_LABEL="User Name"

Now, you could edit that file right there. This will appear straight away on your site, and will handle multi-language properly. But again, this wouldn't survive upgrades very well (if Joomla releases a new version that changes that language file, it'll nuke your changes).

To handle upgrades, they added a new feature in Joomla 1.6 for language overrides. You can add overrides for ANY language file (any component/module/etc) into a separate overrides location, in '/language/overrides/LANG.override.ini'. For example, add the line:

COM_USERS_LOGIN_USERNAME_LABEL="Usr"

Now you've overridden that language string. Add lines for 'MOD_LOGIN_VALUE_USERNAME' etc as well to override the login module and other strings as needed.

Now if you upgrade Joomla, you'll get any changes to those login templates, but won't lose your text changes. You can apply this same process for each language your site is provided in, the overrides will live happily side by side. This will also work for 3rd party components and modules, as long as they're using 'JText::_()' for string output - which they should be.