Creating/modifying dynamic slide generators

This documentation is for Smart Slider 3.3+

Here you can see, where to find the files of the generators, but this is the most important file from them, and probably you want to modify this one: 

Joomla
libraries/nextend2/smartslider/joomla/plugins/generator/[generator main name]/sources/[generator name].php 
or
libraries/nextend2/smartslider/smartslider/plugins/generator/[generator main name]/sources/[generator name].php 

WordPress
wp-content/plugins/nextend-smart-slider3 -pro/library/wordpress/plugins/generator/[generator main name]/sources/[generator name].php 
or
wp-content/plugins/nextend-smart-slider3 -pro/library/smartslider/plugins/generator/[generator main name]/sources/[generator name].php 

Magento
app/code/community/Nextend2/SmartSlider3/library/magento/plugins/generator/[generator main name]/sources/[generator name].php 
or
app/code/community/Nextend2/SmartSlider3/library/smartslider/plugins/generator/[generator main name]/sources/[generator name].php 

The difference between the two paths is, that it is either framework specific, like "joomla" where you can only find the  Joomla generators or it is general, meaning it can be found in all frameworks, so these are the General generators.

If you got the file, you will find something like this, just probably in a more complicated way:

<?php
N2Loader::import('libraries.slider.generator.abstract', 'smartslider');

class N2GeneratorCustom extends N2GeneratorAbstract {

    protected $layout = 'image_extended';

    public function renderFields($form) {
        parent::renderFields($form);

        $filter = new N2Tab($form, 'filter', n2_('Filter'));		
		new N2ElementText($filter, 'mytext', 'My text', '');
    }

    protected function _getData($count, $startIndex) {        
		$data = array();        
		$data[0]['my_variable'] = 'one' . $this->data->get('mytext', '');
		$data[1]['my_variable'] = 'two' . $this->data->get('mytext', '');
		$data[2]['my_variable'] = 'three' . $this->data->get('mytext', '');

        return $data;
    }
}

Let's go through the different parts:

protected $layout = 'image_extended';

We have some predefined layouts, how your slides look like by default, if you wouldn't change anything in the Slide editor. Probably you will want to change the layout, so it doesn't really matter which one you use, but if it would matter for you, you can choose from these values:
image, image_extended, article, product, event, youtube, vimeo, social_post

public function renderFields($form) {
    parent::renderFields($form);

    $filter = new N2Tab($form, 'filter', n2_('Filter'));
    new N2ElementText($filter, 'mytext', 'My text', '');
}

The parent::renderFields($form); is just necessary and it doesn't need explanation. 

What this whole function does is, that this creates the options into the backend, for example you can have text inputs, on/off options, dropdown lists.

The $filter line is the main title of the group of options. You probably don't really need to modify this part, as it is rather for the design to make users better see through everything.

The new N2ElementText line is the important part. This is how you can create options. You can see here what the different parts mean:

new [element type]([group], [identifier], [label], [default value]);

If you check out the different generators, you will find the available element types, but here are a couple examples:

Text input:

new N2ElementText($filter, 'mytext', 'My text', '');

On/off:

new N2ElementOnOff($filter, 'someonoff', 'Visible for XY', 0);

List:

new N2ElementList($filter, 'listofvalues', 'Dropdown list', '0', array(
    'options' => array(
         '0'        => 'None',
         '1'        => 'first option',
         '2'        => 'second option',
         '3'        => 'third option',
    )
));

List with multiselection:

new N2ElementList($filter, 'listofvalues', 'Dropdown list', '0', array(
	'options' => array(
		'0'        => 'None',
		'1'        => 'first option',
		'2'        => 'second option',
		'3'        => 'third option',
	),
	'isMultiple' => true,
	'size'       => 10
));

Radio:

new N2ElementRadio($filter, 'radiooption', 'Pick one', 'a', array(
   'options' => array(
      'a'  => 'First option',
      'b' => 'Second option'
   )
));

This is about everything about the basic options. The advanced options needs more explanation, so I will create a bigger section for that in the  bottom.

Now move on to the next part:

protected function _getData($count, $startIndex) {        
    $data = array();        
    $data[0]['my_variable'] = 'one' . $this->data->get('mytext', '');
    $data[1]['my_variable'] = 'two' . $this->data->get('mytext', '');
    $data[2]['my_variable'] = 'three' . $this->data->get('mytext', '');

    return $data;
}

This part creates the values for your slides. Here all you need is an array, where you have a common variable name at each array value. This is quite a simplified sample code, but you can do anything here, like ask down a database query, put the values into the correct places and return that:

protected function _getData($count, $startIndex) {
    $data = array();
    
    for($i = 0; $i < 5; $i++){
        $result = $database->getResult("SELECT name, description FROM xy WHERE id = '" . $i . "'");
        $helper = array(
           'first_var' => $result['name'],
           'second_var' => $result['description']
        );
        $data[] = $helper;
    }

    return $data;
}

What you need to know about this part is, that the options you created in the part before, you can ask them down like this:

$this->data->get('mytext', '');
Where the first value is the identifier, the second is the default value, in case it doesn't exists:
$this->data->get([identifier],[default value]');

There are two other variables you can use within this function, the $count and $startIndex variables. These are the values of the Slides and Start index at your  Generator's settings. Probably you won't really need them, maybe the $count variable, but I will write their functionality down:
The $count could help you limit down how many datas would you return with the $data variable. The $startIndex is useful, if you want to create multiple dynamic slides with different designs. With this variable you could make your code to not just simply ask down the first values, but rather the Xth values (instead of 1,2,3,4 it could be for example 3,4,5,6).