Custom Programming in Membergate Infinity

Advanced Technique

Membergate Infinity includes new ways that you can make customizations to your Membergate Site, without having to modify the codebase.

That means that we will still be able to apply updates to your site without the problem of overwriting any of the custom coding that you have had done.

PLEASE NOTE:

  • We cannot support any custom programming you have had done, and any changes you have made are done so at your own risk.

  • We cannot guarantee that updates to the site will not cause issues with your custom programming, and any features added or updated in Membergate would likely need to be added to your custom modules.

  • While we recommend that you DON'T customize Membergate, if you MUST do so, we suggest that any changes you do make are made by a programmer who is familiar with Membergate.

Making Application-wide Changes

Application-wide changes are those which need to be made on multiple pages throughout the system.

These changes are usually made at the beginning of a request before the page processes, or at the very end of the request once the page has fully processed.

In both cases, Membergate Infinity includes functionality that allows you to add custom code in either place.

Usually, code that is executed prior to the page loading is done in a file called application.cfm.

Rather than modifying the application.cfm file, you can create a new separate file in the root folder called application-custom.cfm which you can use to add custom code at the beginning of each request.

It is also possible to add code at the beginning of each request depending on the folder that that user is currently browsing.

For example, if you wanted to add custom code that fired on every members page, you can create a file members/application-custom.cfm.

You can create the following custom application files on the site:

  • classifieds/application-custom.cfm
  • members/application-custom.cfm
  • members/forum/application-custom.cfm
  • members/cfmbb/application-custom.cfm
  • products/application-custom.cfm
  • public/application-custom.cfm
  • public/affiliate/application-custom.cfm
  • resources/application-custom.cfm

If you want to add code at the end of each request, you can use the same principle to create a series of custom onRequestEnd.cfm files.

So, for custom code which fires at the end of every request on the site, you can create the file onRequestEnd-custom.cfm in the root folder on the site.

As with the custom application.cfm files, it's also possible to create custom onRequestEnd.cfm files for specific folders in the site as follows:

  • classifieds/onRequestEnd-custom.cfm
  • members/onRequestEnd-custom.cfm
  • members/forum/onRequestEnd-custom.cfm
  • members/cfmbb/onRequestEnd-custom.cfm
  • products/onRequestEnd-custom.cfm
  • public/onRequestEnd-custom.cfm
  • public/affiliate/onRequestEnd-custom.cfm
  • resources/onRequestEnd-custom.cfm

Making Changes to Specific Modules

In order to make changes to specific modules on the site, rather than actually modifying that particular module, you simply need to create a copy of that module, and add it to the custom folder on the site.

When creating a copy of the module, you should remember to maintain the folder structure of Membergate within the custom folder.

As an example, if you wanted to created a custom version of the login page:

members/login.cfm

You would duplicate that file and add it to the custom folder:

custom/members/login.cfm

By default, the system will always check whether or not the custom version of the file exists, and if so use that.

If there is no custom version of the module, it will load the standard Membergate file.

Adding Links in the Control Panel

You can add custom links in the control panel by creating a file at /members/manage/customtools.cfm, and adding your menu links to that.

Those menu link will automatically be added to the Left Nav Panel of the Control Panel on the site.

You can see an example structure for this file below:

<div class="accordionButton navheadleft" admin="cstm">Custom Links</div>
<cfif NOT isDefined("cookie.cstm") or NOT isBoolean(cookie.cstm)>
<cfset cookie.cstm = false>
</cfif>
<div class="accordionContent" style="display:<cfif cookie.cstm>block<cfelse>none</cfif>;">
<a class="adminnavleft" href="../manage/custom_menu_item_1.cfm" title="Custom Menu Item 1">Custom Menu Item 1</a>
<a class="adminnavleft" href="../manage/custom_menu_item_2.cfm" title="Custom Menu Item 2">Custom Menu Item 2</a>
</div>

Benefits

The benefit of handling custom programming in this way means that you no longer have to make any changes to the Membergate codebase, which means we can update your site without overwriting any custom programming that you may have had done.

It also means that all custom programming that you have had done on the site is contained all in one place, meaning that if there are any issues after an update, we can easily check whether or not it's related to any custom programming on the site.