Creating a Joomla system plugin

System plugins are loading in every pages, so it's good to make them, because you can add extra codes to ours without having to put it into our folders, which will be overwritten with the next update.

What you need is to create a folder in here:
plugins/system/

Let's call it example:
plugins/system/ example

Then put three files inside it. The first one should be the index.html, which should only have this code:

<html><body></body></html>

The second file should be a php file, which should have the same name what your folder had, in my case example.php
This will be the file, which is called in everywhere, so it should have the php code, what you would like to run.

The third file is an xml file, which contains the informations of your plugin. This should have the same name too: example.xml
and the code should be something like this:

<?xml version="1.0" encoding="utf-8"?>
<extension version="3.4" type="plugin" group="editors-xtd" method="upgrade">
    <name>Example plugin</name>
    <author>John Doe</author>
    <creationDate>April 2015</creationDate>
    <copyright>Copyright (C) 2005 - 2015 Open Source Matters. All rights reserved.</copyright>
    <license>GNU General Public License version 2 or later; see LICENSE.txt</license>
    <description>Example plugin</description>
    <files>
        <filename plugin="example">example.php</filename>
        <filename>index.html</filename>
    </files>
</extension>

So the important parts are to have the files listed. With these files you could make an installer too, if you just unzip them, Joomla should be able to install your plugin (but you will have to publish it afterwards).

Example - Creating a generator

Create these folders:
plugins\system\ smartslidergenerator\
plugins\system\smartslidergenerator\ newgenerator\

These files with the given code:
index.html

<html><body></body></html>

smartslidergenerator.php

<?php
/**
 * @author        John Doe
 * @copyright (C) 2015 Nextendweb.com
 * @license       GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 **/
defined('_JEXEC') or die('Restricted access');
?><?php
require_once(dirname(__FILE__) . '/../../../libraries/nextend2/nextend/joomla/library.php');
require_once(dirname(__FILE__) . '/../../../libraries/nextend2/nextend/library/library.php');
require_once(dirname(__FILE__) . '/../../../libraries/nextend2/nextend/joomla/libraries/localization/localization.php');
require_once(dirname(__FILE__) . '/../../../libraries/nextend2/smartslider/smartslider/libraries/plugins/N2SliderGeneratorPluginAbstract.php');

N2Loader::import('libraries.plugins.N2SliderGeneratorPluginAbstract', 'smartslider');
class N2SSPluginGeneratorNewGenerator extends N2SliderGeneratorPluginAbstract
{
    public static $group = 'newgenerator';
    public static $groupLabel = 'NewGenerator';

    function onGeneratorList(&$group, &$list) {
        $group[self::$group] = self::$groupLabel;

        if (!isset($list[self::$group])) {
            $list[self::$group] = array();
        }

        $list[self::$group]['newgenerator'] = N2GeneratorInfo::getInstance(self::$groupLabel, 'New generator', $this->getPath() . 'newgenerator')
                                                                    ->setType('image');
    }
    function getPath() {
        return dirname(__FILE__) . DIRECTORY_SEPARATOR;
    }
}
N2Plugin::addPlugin('ssgenerator', 'N2SSPluginGeneratorNewGenerator');

smartslidergenerator.xml

<?xml version="1.0" encoding="utf-8"?>
<extension version="3.4" type="plugin" group="editors-xtd" method="upgrade">
    <name>Smart Slider Custom Generator</name>
    <author>Gabor Racz</author>
    <creationDate>April 2015</creationDate>
    <copyright>Copyright (C) 2005 - 2015 Open Source Matters. All rights reserved.</copyright>
    <license>GNU General Public License version 2 or later; see LICENSE.txt</license>
    <description>Smart Slider custom generator</description>
    <files>
        <filename plugin="smartslidergenerator">smartslidergenerator.php</filename>
        <filename>index.html</filename>
    </files>
</extension>

dynamic.png
This should be the image you want in our backend.

Create a newgenerator folder, and put these files in it:
config.xml

<root>
</root>

generator.php

<?php
/**
* @author    Roland Soos
* @copyright (C) 2015 Nextendweb.com
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
**/
defined('_JEXEC') or die('Restricted access');
?><?php
N2Loader::import('libraries.slider.generator.abstract', 'smartslider');

class N2Generatornewgeneratornewgenerator extends N2GeneratorAbstract
{
    protected function _getData($count, $startIndex) {
        $data = array();
        $data[0]['data'] = 'first data';
        $data[1]['data'] = 'second data';
        $data[2]['data'] = 'third data';
        return $data;
    }
}

Now go to the Extensions -> Manage

click on Discover -> Discover

Select the Smart Slider Custom Generator and install it

Then go to the Extensions -> Plugin Manager

Filter out the system plugins

And put this plugin after our Nextend Smart Slider 3 and Nextend2 Library plugins by clicking on the ordering

And drag 'n drop it lower

Then you can enable this plugin

And if you will go to our backend to create a new dynamic slide

You should be able to see the new generator

And the records, what you made your generator to return

You could put the contents of the newgenerator folder into a zip file too: newgenerator.zip
and then you would be able to install this generator into more websites too, through your Extensions manager.