Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you modify the Login Form in Joomla?

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?

like image 365
CrazyMPh Avatar asked Sep 01 '11 07:09

CrazyMPh


People also ask

How do I change the login page in Joomla?

Joomla will open the Login Page editor. To change the login page in the Template Manager, open the Template Manager and select the Login Page template from the Templates panel. On the Template Manager editor, under the Login Page heading, click on the Edit link.

What is a login module?

The Login Module is a portal module that allows users to type a user name and password to log in. You can add this module on any module tab to allow users to log in to the system. More on creating module tabs.


2 Answers

You do this with so called template overrides. You basically copy a file (where the output of your form happens) to the template directory of your active template. For the login form you it should be like this:

Copy

[joomla]/modules/mod_login/tmpl/default.php

to

[joomla]/templates/[the template you use]/html/mod_login/default.php

It is important to create (if not present) and use the "html" directory in your template directory. Then you edit the new default.php the way you want. The idea is that you do not edit the core files as this is bad practice.

Here is additional information on template overrides: How to override the output from the Joomla! core

like image 30
hbit Avatar answered Sep 28 '22 01:09

hbit


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.

like image 103
KingJackaL Avatar answered Sep 28 '22 03:09

KingJackaL