Writing a Plugin - the basics

The first thing to know about writing a new plugin with the Frog CMS plugin API (Application Program Interface) is that you have enough control to crash the entire Frog CMS application.

In order for Frog to be a flexible application, it needs to be able to do whatever the developer wants. This is why PHP can be added directly in pages. On the other hand, new plugins still require security to be enforced.

What you need to know about Standards

  1. The names of the plugin directory and the plugin id have to be exactly the same and have to be lowercase_underscored.
  2. Use your own plugin id before each function name, so that you will prevent possible function collisions.
  3. You can use classes, but remember that the plugin will be loaded in both the backend and frontend of Frog CMS.

A Hello World plugin

Ok! Let’s start with the basics. The best way to learn is by creating a simple plugin which we will call The Hello World Plugin.

  • Create the plugin directory “hello_world”, inside the frog/plugins directory.
  • Create the index.php file inside the “hello_world” directory.
  • Place the plugin information in the index.php. Here is an example you can use:
Plugin::setInfos(array(
    'id'          => 'hello_world',
    'title'       => 'Hello world!', 
    'description' => 'Allows you to display "Hello World! where you want.', 
    'version'     => '1.0', 
    'website'     => 'http://www.madebyfrog.com/')
);

function hello()
{
    echo 'Hello World!';
}

Note: do not forget to open the php tag <?php

  • Save the index.php file.
  • Login into the Frog Administration page and enable the Hello World plugin by clicking on the checkbox.
  • Create a new page and write <?php hello(); ?>.
  • Publish and save the page.
  • View the newly published page and see how the “Hello World!” string from the plugin’s hello() function is displayed.

Hint: You can also try adding the same code to a snippet or layout.

These are the basics, but you can see that it is quite simple to add your own GLOBAL functions to Frog CMS.


Frog CMS Demo

Public front end website click here
Administration backend click here

Opensource.com admin login info:
login: admin
password: demo123

Help us!

There is no profit here. The more we raise the longer we can keep things going and the better it will get.

Click here to lend your support to: Frog CMS and make a donation at www.pledgie.com !







New domain names with 24h support | london body massage