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

altering the 'easy' memberlist plugin...

Development and Programming

natmags's avatar
natmags
17 posts
16 years ago
natmags's avatar natmags

I’ve taken the code: http://expressionengine.com/docs/development/plugins.html

‘cause I need to show a list of members, their pictures and avatars…

anyhoo, i’m getting an error after tweaking the code…

I need to be able to use in teh tamplate:

{exp:memberlist}

{screen_name} etc

{/exp:memberlist}

Here’s my code… What the hell am I doing wrong?? ;-p

<?php

$plugin_info = array(
  'pi_name' => 'xx',
  'pi_version' => 'xx',
  'pi_author' => 'xx',
  'pi_author_url' => 'xx',
  'pi_description' => 'xx',
  'pi_usage' => Memberlist::usage()
  );

class Memberlist
{

var $return_data = "";

  function Memberlist()
  {
    global $DB;
    global $TMPL;
    
    $query = $DB->query("SELECT screen_name, avatar_filename, photo_filename, occupation
      FROM exp_members WHERE group_id = '1' OR group_id = '5'");

        foreach($query->result as $row) {

            $tagdata = $TMPL->tagdata;
                    
                    foreach ($TMPL->var_single as $key => $val)
                    {
                        if (isset($row[$val]))
                        {
                            $tagdata = $TMPL->swap_var_single($val, $row[$val], $tagdata);
                        }
                    }
                    $this->return_data .= $tagdata; 
        }

  }

  // ----------------------------------------
  //  Plugin Usage
  // ----------------------------------------

  // This function describes how the plugin is used.
  //  Make sure and use output buffering

  function usage()
  {
  ob_start(); 
  ?>
The Memberlist Plugin simply outputs a
list of members and superadmins (staff)

{exp:memberlist}

This is an incredibly simple Plugin.

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

  return $buffer;
  }
  // END

}

?>
       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Don’t know what you are doing in your template but try this :

{exp:memberlist}
{screen_name}, {avatar_filename}, {photo_filename}, {occupation}
{/exp:memberlist}

That should get you what you want 😉

Noticed that your documentation in your plugin just had a single plugin tag but you need to use a pair and place the variables inside it to get at what you need.

Hope that helps a bit.

Best wishes,

Mark

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Actually I just noticed in your first post above (sorry have terrible flu at the moment so didn’t notice it first time) that you are using the code with the plugin pair.

Just to let you know though that I tried this code in a plugin called pi.memberlist.php and it spat out the required information for me.

Do you get anything at all being output and what is the error you are getting?

Best wishes,

Mark

       
natmags's avatar
natmags
17 posts
16 years ago
natmags's avatar natmags

I just used an SQL query in the end… Much quicker ;-p

Cheers though!

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Weird though as I’m not sure why the code would work for me and not for yourself.

Glad you have something working now though.

Best wishes,

Mark

       

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.