Some time ago, I started to create my own components. Everything was working fine, but there was one thing that bugged me (even though it is not really necessary... it just looked strange):
When I create a link to my component, I always ended up with something like this in my menu manager:
Similar thing for the menu item type:
I felt like I somehow missed something, but the tutorials did not say anything about it. After playing around for a little while, I found out that the solution actually is pretty simple: The site > views > viewname > tmpl > default.xml file specifies these texts. Joomla! will look for these keys in the language files. Thus, you just need to add some entries to the language files and voila - everything looks nice and clean, just like this:
Step-By-Step:
Let's assume you already created the default.xml file with contents similar to these:
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_TRAININGMATERIAL_TRAININGMATERIAL">
<message>COM_TRAININGMATERIAL_TRAININGMATERIAL</message>
</layout>
</metadata>
Now have a look into your filesystem - open the "joomla" folder. There are two "language" folders - one for the front-end, one for the back-end - you will find this one in the "administrator" folder. As the menu manager is a part of the back-end, we are looking for the administrator/language folder.
This folder contains folders for the installed languages - for example "en-GB". Open your standard language folder. Here you will find lots of .ini and .sys.ini files. Now go on and create your own .sys.ini file - for example "en-GB.com_trainingmaterial.sys.ini". Open it with your favorite text editor.
I copied the contents from another language file and didn't delete the comments at the top - now my language file looks like that:
; Joomla! Project
; Copyright (C) 2005 - 2012 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 - No BOM
COM_TRAININGMATERIAL="Training Material"
COM_TRAININGMATERIAL_MANAGEMENT_VIEW_DEFAULT_TITLE="Management"
COM_TRAININGMATERIAL_TRAININGMATERIAL_VIEW_DEFAULT_TITLE="Frontend"
COM_TRAININGMATERIAL_TRAININGMATERIAL="Frontend"
COM_TRAININGMATERIAL_MANAGEMENT="Backend / Management"
The first three entries are the ones for the menu manager. Note the "VIEW_DEFAULT_TITLE" part - even though it is not in your default.xml, it needs to go into the language file. Joomla! will put it all together.
The other entries are for the menu item type manager. Try it!
Any questions, comments? Feel free to comment on this post!
When I create a link to my component, I always ended up with something like this in my menu manager:
Similar thing for the menu item type:
I felt like I somehow missed something, but the tutorials did not say anything about it. After playing around for a little while, I found out that the solution actually is pretty simple: The site > views > viewname > tmpl > default.xml file specifies these texts. Joomla! will look for these keys in the language files. Thus, you just need to add some entries to the language files and voila - everything looks nice and clean, just like this:
Step-By-Step:
Let's assume you already created the default.xml file with contents similar to these:
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_TRAININGMATERIAL_TRAININGMATERIAL">
<message>COM_TRAININGMATERIAL_TRAININGMATERIAL</message>
</layout>
</metadata>
Now have a look into your filesystem - open the "joomla" folder. There are two "language" folders - one for the front-end, one for the back-end - you will find this one in the "administrator" folder. As the menu manager is a part of the back-end, we are looking for the administrator/language folder.
This folder contains folders for the installed languages - for example "en-GB". Open your standard language folder. Here you will find lots of .ini and .sys.ini files. Now go on and create your own .sys.ini file - for example "en-GB.com_trainingmaterial.sys.ini". Open it with your favorite text editor.
I copied the contents from another language file and didn't delete the comments at the top - now my language file looks like that:
; Joomla! Project
; Copyright (C) 2005 - 2012 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8 - No BOM
COM_TRAININGMATERIAL="Training Material"
COM_TRAININGMATERIAL_MANAGEMENT_VIEW_DEFAULT_TITLE="Management"
COM_TRAININGMATERIAL_TRAININGMATERIAL_VIEW_DEFAULT_TITLE="Frontend"
COM_TRAININGMATERIAL_TRAININGMATERIAL="Frontend"
COM_TRAININGMATERIAL_MANAGEMENT="Backend / Management"
The first three entries are the ones for the menu manager. Note the "VIEW_DEFAULT_TITLE" part - even though it is not in your default.xml, it needs to go into the language file. Joomla! will put it all together.
The other entries are for the menu item type manager. Try it!
Any questions, comments? Feel free to comment on this post!
Argh! This was bugging the hell out of me for weeks and for the life of me couldn't work out how to resolve it..
ReplyDeleteThank you for this! I'm pretty sure this isn't mentioned once in any online documentation!
You're welcome! Thanks for the comment ;-)
ReplyDelete