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

Newbie Stuck

Development and Programming

scubby's avatar
scubby
4 posts
15 years ago
scubby's avatar scubby

Sorry if this question has been answered a million times, but I looked and didn’t see it.

I had a plugin that worked well in EE 1.6.8, but after I upgraded to EE 2.1.3 and recoded it to match the new examples, I got an error that the tag cannot be processed. So I went back to basics and tried the “memberlist” plugin from the user guide (just copied and pasted) and I get the same error:

Error

The following tag cannot be processed:

{exp:memberlist}

Please check that the ‘memberlist’ module is installed and that ‘memberlist’ is an available method of the module

Is there something obvious I am missing? The plugin file resides in ./system/expressionengine/third_party/memberlist/pi.memberlist.php and I am calling it in a template with {exp:memberlist}, just as the usage says. The permissions are set to 777 on the file and directories. It shows up in the list of plugins in the CP.

Any help nudging me in the right direction would be greatly appreciated!

<?php

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

$plugin_info = array(
  'pi_name' => 'Member List',
  'pi_version' => '1.0',
  'pi_author' => 'Jane Doe',
  'pi_author_url' => 'http://example.com/',
  'pi_description' => 'Returns a list of site members',
  'pi_usage' => Memberlist::usage()
  );

/**
 * Memberlist Class
 *
 * @package            ExpressionEngine
 * @category        Plugin
 * @author            Jane Doe
 * @copyright        Copyright (c) 2010, Jane Doe
 * @link            http://example.com/memberlist/
 */

class Memberlist
{

var $return_data = "";

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

    /**
     * Memberlist
     *
     * This function returns a list of members
     *
     * @access    public
     * @return    string
     */

  function __construct()
  {
    $this->EE =& get_instance();
    $query = $this->EE->db->query("SELECT screen_name
      FROM exp_members LIMIT 15");

    foreach($query->result_array() as $row)
    {
      $this->return_data .= $row['screen_name'];
      $this->return_data .= "
";
    }
  }

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

    /**
     * Usage
     *
     * This function describes how the plugin is used.
     *
     * @access    public
     * @return    string
     */
    
  //  Make sure and use output buffering

  function usage()
  {
  ob_start(); 
  ?>
The Memberlist Plugin simply outputs a
list of 15 members of your site.

{exp:memberlist}

This is an incredibly simple Plugin.

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

  return $buffer;
  }
  // END

}
/* End of file pi.memberlist.php */ 
/* Location: ./system/expressionengine/third_party/memberlist/pi.memberlist.php */
       
Manuel Payano's avatar
Manuel Payano
144 posts
15 years ago
Manuel Payano's avatar Manuel Payano

Could you try this?

Change: function __construct() to: function Memberlist()

       
scubby's avatar
scubby
4 posts
15 years ago
scubby's avatar scubby

Perfecto! It worked like a charm.

Thanks, Manuel!

       
Jérôme Coupé's avatar
Jérôme Coupé
122 posts
15 years ago
Jérôme Coupé's avatar Jérôme Coupé

Hello Guys,

::warning – PHP NoOb ahead::

Ran exactly in the same problem.

Looks like using __construct() is throwing an error at me as well (using copy paste from the docs + with a very very simple plugin I wrote)

The following tag cannot be processed: {exp:html_strip} Please check that the ‘html_strip’ module is installed and that ‘html_strip’ is an available method of the module

Changing the constructor method to match the name of the class did the trick!

This seems to be in complete contradiction with the official guidelines for class and method naming. Basically I have a plugin that does not work when coding according to official guidelines and the only way I can get it to work is by doing what is labeled as incorrect in the doc.

Am I doing something wrong? Do I miss something (not a PHP wizard here)? Working with EE v 2.1.3 Build: 20101220 PHP infos tells me that PHP 5.3.2 is running on the server.

Code that works

<?php

$plugin_info = array(
    'pi_name' => 'Html_strip',
    'pi_version' =>'1.0',
    'pi_author' =>'Me',
    'pi_author_url' => 'http://www.mysite.com',
    'pi_description' => 'Strips HTML tags',
    'pi_usage' => Html_strip::usage()
    );


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

class Html_strip {
    
    var $return_data = "";
    
    public function Html_strip()
    {
        $this->EE =& get_instance();
        $this->return_data = strip_tags($this->EE->TMPL->tagdata);
    }


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

    /**
     * Usage
     *
     * This function describes how the plugin is used.
     *
     * @access    public
     * @return    string
     */
    
    //  Make sure and use output buffering

    function usage()
    {
        ob_start(); 
        ?>

            The html_strip plugin strips html from your data. No parameters, no nothing.
    
            {exp:html_strip}
            content to strip
            {/exp:html_strip}
    
            This is an incredibly simple Plugin.

        <?php
        $buffer = ob_get_contents();
        
        ob_end_clean(); 
        
        return $buffer;
    }
    // END

}

/* End of file pi.html_strip.php */ 
/* Location: ./system/expressionengine/third_party/plugin_name/pi.html_strip.php */

Code that does not work

<?php

$plugin_info = array(
    'pi_name' => 'Html_strip',
    'pi_version' =>'1.0',
    'pi_author' =>'Me',
    'pi_author_url' => 'http://www.mysite.com',
    'pi_description' => 'Strips HTML tags',
    'pi_usage' => Html_strip::usage()
    );


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

class Html_strip {
    
    var $return_data = "";
    
     function __construct()
    {
        $this->EE =& get_instance();
        $this->return_data = strip_tags($this->EE->TMPL->tagdata);
    }


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

    /**
     * Usage
     *
     * This function describes how the plugin is used.
     *
     * @access    public
     * @return    string
     */
    
    //  Make sure and use output buffering

    function usage()
    {
        ob_start(); 
        ?>

            The html_strip plugin strips html from your data. No parameters, no nothing.
    
            {exp:html_strip}
            content to strip
            {/exp:html_strip}
    
            This is an incredibly simple Plugin.

        <?php
        $buffer = ob_get_contents();
        
        ob_end_clean(); 
        
        return $buffer;
    }
    // END

}

/* End of file pi.html_strip.php */ 
/* Location: ./system/expressionengine/third_party/plugin_name/pi.html_strip.php */
       
bryantAXS's avatar
bryantAXS
50 posts
15 years ago
bryantAXS's avatar bryantAXS

I also ran into this __constructor() vs class_name() constructor issue when building plugins. Someone at EL should really change the documentation.

       
scubby's avatar
scubby
4 posts
15 years ago
scubby's avatar scubby

This looks to have been reported in the Bug Tracker and has a status (as of today) of “Fixed in next release”.

Fingers crossed.

       

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.