Customizing Admin templates

From time to time you need to change an admin form. Perhaps you need to 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 ahead, find the right file(s) and edit them.

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

Fortunately, for minor things like tweaking admin templates CMSMS handles this nicely.

Let us say you're using the CompanyDirectory module as more like a member database, and you want to remove a few fields that you won't need, like fax etc.

So you want to remove the fax field from the CompanyDirectory add/edit company forms. This is simple enough to do:

  • Create a new directory called templates underneath assets/module_custom/CompanyDirectory.
  • Find the appropriate .tpl file in modules/CompanyDirectory/templates
  • Copy that template to assets/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 below. Simply remove this text.
<div class="pageoverflow">
<p class="pagetext">{$faxtext}</p>
<p class="pageinput">{$inputfax}</p>
</div>

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 edit more things in the template, to customize the appearance of any module. And when you upgrade to a newer version of the module, your changes will be intact.