We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Creating a Plugin

Development and Programming

kohnt01's avatar
kohnt01
11 posts
12 years ago
kohnt01's avatar kohnt01

I’m trying to create my first plugin with EE and it’s not letting me use the syntax after doing so.

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$plugin_info = array(
  'pi_name'         => 'vBulletin Usergroups',
  'pi_version'      => '1.0',
  'pi_author'       => 'NGU',
  'pi_author_url'   => 'http://website.com/',
  'pi_description'  => 'vBulletin Elite Usergroup',
  'pi_usage'        => Vbulletinusergroups::usage()
);

class Vbulletinusergroups
{

    public $return_data = "";

    // --------------------------------------------------------------------

    /**
     * Vbulletinusergroups
     *
     * This function returns a list of members
     *
     * @access  public
     * @return  string
     */
    public function __construct()
    {

// I'm going to hide this bit for privacy

    }

    // --------------------------------------------------------------------

    /**
     * Usage
     *
     * This function describes how the plugin is used.
     *
     * @access  public
     * @return  string
     */
    public static function usage()
    {
        ob_start();  ?>

The Vbulletinusergroups Plugin allows you to detect if they are a member of a usergroup on vB.

    {exp:Vbulletinusergroups}

    <?php
        $buffer = ob_get_contents();
        ob_end_clean();

        return $buffer;
    }
    // END
}
?>
/* End of file pi.Vbulletinusergroups.php */
/* Location: ./system/expressionengine/third_party/Vbulletinusergroups/pi.Vbulletinusergroups.php */

Is there anything wrong with this? When I use {exp:Vbulletinusergroups} in a template I’m getting:

Error

The following tag has a syntax error:

{exp:Vbulletinusergroups}

Please correct the syntax in your template.

       
travisb's avatar
travisb
172 posts
12 years ago
travisb's avatar travisb

Just a wild guess since I haven’t written a plugin, but are you supposed to close out php with the ?>, or leave it off?

       
Bhashkar Yadav's avatar
Bhashkar Yadav
727 posts
12 years ago
Bhashkar Yadav's avatar Bhashkar Yadav

Hi Kohnt01,

The plugin tag {exp:Vbulletinusergroups} will call the __construct method of your plugin so you need to check the code within it.

You can output like:

$this->return_data = 'ABCD';

For the above your plugin tag, it will return ABCD.

Hope, it would help you.

       
kohnt01's avatar
kohnt01
11 posts
12 years ago
kohnt01's avatar kohnt01
Hi Kohnt01, The plugin tag {exp:Vbulletinusergroups} will call the __construct method of your plugin so you need to check the code within it. You can output like:
$this->return_data = 'ABCD';
For the above your plugin tag, it will return ABCD. Hope, it would help you.

I did actually have this, but if you look in the code I hid it so it wasn’t shared with the public. I’ve put in your example and it’s still telling me that syntax doesn’t exist, so please let me know if I’ve done anything wrong:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$plugin_info = array(
  'pi_name'         => 'vBulletin Usergroups',
  'pi_version'      => '1.0',
  'pi_author'       => 'NGU',
  'pi_author_url'   => 'http://website.com/',
  'pi_description'  => 'vBulletin Elite Usergroup',
  'pi_usage'        => Vbulletinusergroups::usage()
);

class Vbulletinusergroups
{

    public $return_data = "";

    // --------------------------------------------------------------------

    /**
     * Vbulletinusergroups
     *
     * This function returns a list of members
     *
     * @access  public
     * @return  string
     */
    public function __construct()
    {

$this->return_data = 'ABCD'; 
    }

    // --------------------------------------------------------------------

    /**
     * Usage
     *
     * This function describes how the plugin is used.
     *
     * @access  public
     * @return  string
     */
    public static function usage()
    {
        ob_start();  ?>

The Vbulletinusergroups Plugin allows you to detect if they are a member of a usergroup on vB.

    {exp:Vbulletinusergroups}

    <?php
        $buffer = ob_get_contents();
        ob_end_clean();

        return $buffer;
    }
    // END
}

?>
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.