|
One of my clients needed to have some pieces of Jom Social (com_community) modified but we did not want to change the Jom Social core PHP files.
Jom Social does provide information about how to create template specific overrides for the Jom Social Template routines. This follows the standard override methodolgy of creating a html folder under your chosen template's home folder then adding a folder for the component in this case com_community. Then you copy over the exisiting routines that you wish to modify, you can now edit them in your favourite editor and save them to this new location upload them to the host and Jom Social (com_community) will pickup your new versions.
What if you want to change the terminolgy, the choice of words that will appear on your layouts ? At first it appeared that we would have to add our custom versions to the main language files, that felt like we were tampering with the core of Jom Social.
After some experimentation, because the Joomla Documentation is sadly in need of being written up in a way that is actually useful, I figured out that I could make Joomla load an add-on Language file that would actually update the existing constants to reflect the new wording.
Since the custom versions of the files are located in the html folder of the front end template we can use the dirname(__FILE__) function to pickup the base path for loading our language file.
Here is the folder structure :
/templates/[front end template]/html/[component]/language/en-GB/
where is [front end template] is your default template set in the administration (back end) and [component] is the name of the component (or module). The default language is en-GB however you will need to create folders for each language that you are supporting and of course provide translated versions of your text strings.
In your modified component (or module) you will need to add the following lines at the top of the PHP file immediately below the defined('_JEXEC') or die(); line
// the following lines provide a mechnism to load language files for this version of the register.index.php file for jom social (com_community) define( 'MMCIBASEPATH', dirname(__FILE__) ); $mmciLang =& JFactory::getLanguage(); $mmciLang->load("com_community",MMCIBASEPATH,'en-GB',true);
The parameters on the load line are as follows :
boolean load ([string $extension = 'joomla'], [string $basePath = JPATH_BASE], [string $lang = null], [boolean $reload = false])
- string $extension: The extension for which a language file should be loaded
- string $basePath: The basepath to use to the folder within which the language folder resides
- string $lang: The language to load, default null for the current language, this will need to be supplied so that you can supply the next parameter.
- boolean $reload: Flag that will force a language to be reloaded if set to true. In our case this is needed to cause the load to override the existing constant values.
You can find the Joomla API reference here :
JLanguage::load
|