Did you know that you can change any of the default text on your Joomla site without touching the language files?
The feature that makes this possible is called "Language Overrides". If you're new to "overrides", check out this introductory tutorial.
In this tutorial, we'll show you how to use Language Overrides to safely customize your site's text.
A language string is composed of two parts: a specific language constant and its value.
COM_OSCAMPUS to the left of the equal sign in the image above is a language string constant. The
OSCampus Pro text to the right of the equal sign is a language string value.
The constant is needed for Joomla code. The value is the very text which will be displayed in a label.
Without this feature, if you wanted to write your own labels and text messages you need to actually go to your /language/ folder and replace language strings.
You now don't need any knowledge of coding to change a text of your Joomla labels. It doesn't affect the core files. Delete your changes and revert back. It is just a piece of cake!
For the purpose of this tutorial, you will replace the "Become a member to view this session" text for your OSCampus Pro sign-up page by its string.
First let's acess the language overrides
- Go to Extensions > Language(s) > Overrides:
You will see the Languages: Overrides administrative page:
- Click New.
You will see the Languages: Edit Override administrative page:
- Locate the Search For field. Make sure the field displays the Value option:
- Enter Become a member into the Search field.
- Click on the blue Search button:
You will see the string and its text appeared in the Search Results box:
- Click anywhere inside that box.
- You will see the text "Become a member to view this session" appeared in the Text box. Replace it with the one you prefer.
- Click Save & Close.
You will be taken to the administrative Languages: Overrides page with your new override listed:
If you would like to further tweak the text of your newly created language override, simply click on the constant:
You will be once again taken to already familiar to you Languages: Edit Override administrative page.
- Edit the language string text inside the Text box.
- Click Save & Close.
Adding Images to Language Strings
One Joomlashack user asked if they can include images in language overrides. The answer would be: "Yes, you can but you may not need to."
Technically, the Language Override allows you to place HTML tags, like the
img, either inside or instead of your language text strings. If you want, you can edit your Language Override to end up with the string looking similar to the one in the image below:
However, the best approach with content managment systems is normally to keep your content separate from presentation. Before you do this, check to see if you have better ways to get the same result.