Integrate Custom PHP Code
Posted by - NA -, Last modified by Mark [Elevated X Support] on 01 March 2018 05:29 PM
|
|
Integrate Custom PHP Code Note - This is not part of our standard installation. Use of our tech support staff for assistance with custom coding will result in additional support charges. Sometimes, a custom piece of PHP code needs to be integrated into the CMS. Here is how you can set this up. Step 1) Go to the file cmsinclude.ini.php. Under the requires tab, you'll see a list of files that are loaded when a user accesses the members area. These files are part of the CMS, but you can add to them: require[] = "trial.php"
Under require3, you can add your own lines that will include a PHP file:require[] = "myfile1.php"
Note: Older installs may have lines that use require1, require2, require3, like so:require1 = "trial.php"
Regardless of if you see this, we recommend you still use require[] for any adding new lines instead of the numerical version.Step 2) Create the file myfile1.php and put in any custom code that's needed. Altering the output from the CMS Sometimes, a custom piece of PHP needs to alter the output from the CMS. Here's how this can be done: Step 1) Go back to the file cmsinclude.ini.php. Under the flags tab, you'll want to add the following: What this does is tell the CMS to load a function named "myFunction" after the template output has been generated. Step 2) Within myfile1.php (or whatever filename you added to the system up above), add the following function
Note - The name of the function you'll need to do is based on what you put within the POSTPROCESS setting. So if you set the POSTPROCESS flag to "Custom", then you will need to call your custom function "Custom" Note - As of build 3280, multiple functions are supported. Example: POSTPROCESS=customfunction1,customfunction2,customfunction3
Adding Smarty Variables to the CMS Sometimes, custom smarty variables need to be assigned within the system Step 1) Go back to the file cmsinclude.ini.php. Under the flags tab, you'll want to add the following: What this does is tell the CMS to load a function named "variable_append" after the template output has been generated. Step 2) Within myfile1.php (or whatever filename you added to the system up above), add the following function
Note - The name of the function you'll need to do is based on what you put within the SMARTY_CUSTOMIZE_VARIABLES setting. So if you set the SMARTY_CUSTOMIZE_VARIABLES flag to "Custom", then you will need to call your custom function "Custom" Note - Multiple functions are allowed here. Example: SMARTY_CUSTOMIZE_VARIABLES=customfunction1,customfunction2,customfunction3 | |
|