-
Notifications
You must be signed in to change notification settings - Fork 1
Creating a module
AskingQuestions edited this page Feb 4, 2017
·
2 revisions
Start by creating a file in Websom/Website/Modules/ name it MyModule.php.
Add this code to MyModule.php
<?php
function MyModule_Status() { //This is called by websom when the module is loaded.
return true; //Return true to let websom know your module is working.
}
function MyModule_Structure() { //This is called by websom asking for an array of keys/values to create tables in the database, it is optional.
return [
"mytable" => "`mycolumn` VARCHAR(256), `another` INT NOT NULL" //This will make the table mytable with the sql structure as the value.
];
}
function MyModule_Info() { //This should return info about the module.
return [
"major" => "1",
"minor" => "0",
"description" => "My simple module"
"website" => "None",
"author" => "A person",
"license" => "https://en.wikipedia.org/wiki/MIT_License"
];
}
?>
Now check if your module is loaded by typing info MyModule into the console, this should display the info above.
Next you should load your module, to do this type reload in the console. To check the tables you can use phpmyadmin.
NOTE: websom prefixes table names with the module id. See bellow for help.
Getting a module table name, use the function Get_Table("MyModule.mytable") to return a string containing the real table name that you can use in a mysql query.
Exporting your module for use by others is done in the console as well, simply type pack MyModule hit enter 2 times and look in the ExportedModules folder in your Document_root.