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
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?
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.