Introduction
In this article I will show you to create a simple Jomres plugin called Hello World.
It assumes that you're already familiar with working with PHP scripts, the purpose here is to demonstrate how you can create a simple plugin with code that can be used on both Joomla and Wordpress installations of Jomres. It also assumes that you have a working installation of Jomres up and running.
Once it has been created you will be able to enter the "hello_world_simple" task in the address bar of your browser, like this :
And you will see simple output like this in the page
There are other ways to display the output, but in this example we'll stick with this simple example.
Da code
Ok, let's get started. First you need to navigate to your /jomres/remote_plugins directory and create a new directory called hello_world_simple
Once that has been done, you need to create your plugin information file. The file should be called plugin_info.php and it'll contain the following data :
<?php
defined( '_JOMRES_INITCHECK' ) or die( '' );
class plugin_info_hello_world_simple
{
function __construct()
{
$this->data=array(
"name"=>"hello_world_simple",
"category"=>"Misc",
"marketing"=>"The simplest possible Jomres Plugin that displays Hello World",
"version"=>(float)"1.0",
"description"=> "The simplest possible Jomres Plugin that displays Hello World.",
"lastupdate"=>"2017/06/13",
"min_jomres_ver"=>"9.9.4",
"manual_link"=>'',
'change_log'=>'',
'highlight'=>'',
'image'=>'',
'demo_url'=>'',
'third_party_plugin_latest_available_version' => "",
'developer_page'=>''
);
}
}
As you can see the class name and the name in the $this->data array "name" index must match the plugin name and the parent directory.
Save that file. Next you need to create a new file called j06000hello_world_simple.class.php in the same directory.
The basic structure of a plugin file is that it starts with JNNNNNXXXXX.class.php
For a proper breakdown of Jomres trigger numbers, see the README.md on Github (you'll need to scroll to the bottom),
In this file you will need to enter the following lines
<?php
defined('_JOMRES_INITCHECK') or die('');
class j06000hello_world_simple
{
public function __construct()
{
$MiniComponents = jomres_singleton_abstract::getInstance('mcHandler');
if ($MiniComponents->template_touch) { $this->template_touchable = false; return; }
echo "<h1>Hello World!</h1>";
}
public function getRetVals() {
return null;
}
}
This is a very simplistic example of a plugin. If you were to copy it you would only need to change the name of the class (this is what defines the name of the "task" that you will call) and the actual code performing the work, in this case just
echo "<h1>Hello World!</h1>";
Now, before Jomres can use this script it needs to be added to the internal Jomres registry. Once you have saved the file you need to rebuild the registry, this will tell Jomres that the script files exist.
You only need to rebuild the registry once, when you create the file ( including after copying a core file to a directory in /remote_plugins/xxxxx this tells Jomres to use this one instead of the original.)
Ok, that's it, all done! You can now call the task directly through the browser's address bar, as shown at the top of this page, by entering something like http://localhost/test/index.php?option=com_jomres&task=hello_world_simple in the browser.
There are other ways it can be called too, for example through shortcodes, or Jomres ASAModule.