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