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 question about plugins and giving access to variables.

Development and Programming

Zac G.'s avatar
Zac G.
268 posts
16 years ago
Zac G.'s avatar Zac G.

Hi Folks,

I’m hoping to make a plugin that I would give access to the screen_name and member_id of members of a particular member group.

So far, I have just modified the memberlist plugin example in the documentation and it is working smashingly:

function Memberlist()
  {
    global $DB;
    global $TMPL;
    
    $group_id = $TMPL->fetch_param('group_id');
    
    $query = $DB->query("SELECT screen_name
      FROM exp_members WHERE group_id = '$group_id'");

    $this->return_data .="Number of results:" . $query->num_rows."<br>";
    foreach($query->result as $row)
    {
      $this->return_data .= $row['screen_name'];
      $this->return_data .= "
";
    }

So right now to call the plugin I do this:

{exp:memberlist member_group="1"}

What I would like to be able to do is this:

{exp:memberlist member_group="1"}
Name: {screen_name}
Member Id: {member_id}
{/exp:memberlist}

Could anyone give me a little direction on how to go about this, or an example to work from?

Thanks! Zac

       
Robin Sowell's avatar
Robin Sowell
13,160 posts
16 years ago
Robin Sowell's avatar Robin Sowell

You’re on the right track- you’ll just need to make more use of the template class to swap out variables for content. Check out Data in tag pairs for the gist of what you want.

Then I did a quick skim, looking for a fairly simple first party plugin you could take a look at- Links mentioned or Twitter timeline might be good choices.

In ‘Links mentioned’ take a look at how it handles the swap:

/*---------------------------------------
         Parse Template
        ----------------------------------------*/

        if (empty($this->link_params))
        {
            return false;
        }

        $return = '';

        foreach ($this->link_params as $link)
        {

            $tagdata = $TMPL->tagdata;

etc...

That help get things going?

       

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.