Skip to main content.

Customizing Module Strings and Admin Templates

16/8-08 at 10.21 by: Robert Campbell

From time to time you need to tweak the strings that are displayed in a module, or maybe change an admin form or two. Possibly remove some of the optional fields so that end users don't get confused. and because CMSMS is an open source package, and is written in PHP you can go head, find the right file(s) and tweak them to you're hearts content.

However, this has challenges. The next time that a new version of that particular module is released you'll have to re-do all of these changes because the upgrade will replace your modified files.

Fortunately, for minor things like tweaking admin templates, or changing lang strings CMS handles this nicely.

Lets say you're using the CompanyDirectory module as more like a member, and you want to change a few strings, and remove a few fields that you won't need (like Fax), etc.

First the language strings. CMSMS supports overriding just the language strings that you want to override.. it's a simple two step process:

  • Create a directory named module_custom/<ModuleName>/lang underneath your CMSMS root directory.

    i.e: mkdir -p module_custom/CompanyDirectory/lang

  • Next, create a file entitled en_US.php in that directory, and place in it the PHP file header and footer and just the lang strings you want to override.

    i.e: vi module_custom/CompanyDirectory/lang/en_US.php

    <?php
    $lang['addcompany'] = 'Add Member';
    ?>

Now when you view the CompanyDirectory administration panel, you will see the words 'AddCompany' displaying at the bottom of the companies list. You can use this mechanism to override any string in the module. You will want to look at the original en_US.php file to find the keys for the strings you want to change.

You can use this technique to override strings in any language as well, just create an fr_FT.php file in the module_custom/<ModuleName>/lang directory, and adjust the strings in the same way.   In this manner if you have an  MLE install or multiple administrators working in different languages you can make the changes consistent across all languages.

Next the templates. Lets say you want to remove the Fax field from the CompanyDirectory add/edit company forms. This is simple enough to do as well:

  • Create a new directory entitled templates underneath module_custom/CompanyDirectory.

    i.e: mkdir -p module_custom/CompanyDirectory/templates

  • Find the appropriate .tpl file in modules/CompanyDirectory/templates
  • Copy that template to module_custom/CompanyDirectory/templates

    i.e: cp modules/CompanyDirectory/templates/editcompany.tpl module_custom/CompanyDirectory/templates

  • Edit the new file to remove the fax field.

    You will notice in the editcompany.tpl file some text that looks like:

    <div class="pageoverflow">
    <p class="pagetext">{$faxtext}:</p>
    <p class="pageinput">{$inputfax}</p>
    </div>

    Simply remove this text,

Now when you add a new company in the CompanyDirectory module the fax field will no longer be present.

These simple steps can be used over and over again (just add more strings to the lang files) or edit things in the template, to customize the appearance of any module.  And when the you upgrade to a newer version of the module, you're changes will be intact.

02/7-10 at 05.59 by: Cheap-Womens
<a href=" http://www.giantsupplier.com/Womens-Clothing/Cheap-Womens-Dresses">Cheap Fashion Sexy Womens Dresses</a> <a href=" http://www.giantsupplier.com/men-s-clothing/Mens-T-shirts">Shop Online Mens T-Shirts</a> <a href=" http://www.giantsupplier.com/Swimwear-Bikini">Womens Swimwear</a> <a href=" http://www.giantsupplier.com/The-latest-high-heel-shoes/YSL-High-heel-shoes">Discount YSL high heel shoes On Sale</a> <a href=" http://www.giantsupplier.com/The-latest-high-heel-shoes/Discout-Chlistian-Louboutin-High-heel-Shoes">Discount Christian Louboutin Online</a> <a href=" http://www.giantsupplier.com/cheap-mbt-shoes">MBT Walking Shoes Sale</a> <a href=" http://www.giantsupplier.com/Women-s-Sunglasses">Cheap Sunglasses</a> <a href=" http://www.giantsupplier.com/Womens-Clothing/Cheap-Womens-Suits">Discount Womens Tracksuit</a> <a href=" http://www.giantsupplier.com/cheap-supra-shoes">discount supra shoes</a>
29/6-10 at 20.35 by: SjG
I keep coming back to this page when I forget the syntax :) Also note you can override admin strings! For example, if you create a file in admin/custom/lang/en_US/admin.inc.php that's contains strings, you can change the names of the extra fields, e.g., $lang['admin']['extra1'] = 'My Field Name'; which is good for clients who get confused by the more generic names.
10/6-10 at 05.26 by: dickert
http://www.videorolls.com/watch/CMSMS - here's what I also consider important while dealing with CMSMS
16/8-08 at 18.03 by: Milhaus
Nice article for beginners among us! I think this could be useful for many people, so I would like to translate it and post it to Czech CMSMS site (of course with a link). May I?
Written by:
Comment:
Write the chars you see in the square
This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)