Templating/Shortcodes Utilizing e107's Templating and Shortcode engine.

Creating Shortcodes

Create an empty file in your plugin directory called myplugin_shortcodes.php where myplugin is the name of your plugin's folder.
Add the following code replacing myplugin with the name of your plugin's folder.

class myplugin_shortcodes extends e_shortcode
{
    // Enter Shortcode methods here
}

Add your shortcode methods using the sc_ prefix and what follows in lower case.
In the example below we will create a shortcode for {SAY_HELLO} which will say 'hello' to the logged in user.
class myplugin_shortcodes extends e_shortcode
{
    function sc_say_hello($parm='')
    {
       return "Hello ".USERNAME;
    }
}

Advanced example using shortcode parameters. eg. {SAY_HELLO: name=john}

class myplugin_shortcodes extends e_shortcode
{
    function sc_say_hello($parm)
    {
       return "Hello ".vartrue($parm['name']);
    }
}

Advanced example using database values. See $sc->setVars($row); in example below.

class myplugin_shortcodes extends e_shortcode
{
    function sc_say_hello($parm)
    {
       return "Hello ".vartrue($this->var['name']);
    }
}

Thursday 13 June 2013 - 17:00:00 admin,