Introducing custom modules

Custom modules allow you to create bespoke functionality on a website.

Modules exist within the modules folder. You can name a module anything you like, but it has to be unique. Both custom modules and built in modules exist in this same folder.

Its  a good idea to name modules with your sites name at the start, so you can easily identify custom modules vs standard modules.

Within the module folder, your custom code exists within an index.php file.

The index file needs a function that matches the name of the module, which will be executed when the module is used on the site.

The function can take a number of parameters, which are passed from the Unicity module code.

Within that function, you can execute any PHP code you wish. Any HTML to return to the browser should be returned from the function.

Example module

<?php
	function mymodule($var1){
	
		if($var1 == "test"){
			$output = '<p>HTML goes here</p>';
		}else{
			$output = '<p>Other HTML goes here</p>';
		}
		
		return $output;
		
	}
?>

Read more...