Skip to content

Instantly share code, notes, and snippets.

@husseinalhammad
Created July 21, 2018 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save husseinalhammad/ab59aab7f9d3cd40c700252e6c4e48df to your computer and use it in GitHub Desktop.
Save husseinalhammad/ab59aab7f9d3cd40c700252e6c4e48df to your computer and use it in GitHub Desktop.
Perch Members - dashboard widget example
<?php
return function(){
$API = new PerchAPI(1, 'perch_members');
$Members = new PerchMembers_Members($API);
$HTML = $API->get('HTML');
$Lang = $API->get('Lang');
$Paging = $API->get('Paging');
$Paging->set_per_page(10);
$members = $Members->all($Paging);
$title = $HTML->wrap('h2', $Lang->get('Members'));
$button = '<a class="button button-small button-icon icon-left action-info" href="'.$HTML->encode(PERCH_LOGINPATH.'/addons/apps/perch_members/edit/').'"><div>'.PerchUI::icon('core/menu', 8).'<span>'.$Lang->get('View All').'</span></div></a>';
$header = $HTML->wrap('header', $title.$button);
$body = '';
if (PerchUtil::count($members)) {
$items = [];
foreach($members as $Member) {
$s = '';
$s .= '<a href="'.PerchUtil::html(PERCH_LOGINPATH.'/addons/apps/perch_members/edit/?id='.$Member->id()).'">';
$s .= $HTML->encode($Member->first_name() .' '. $Member->last_name());
$s .= '</a>';
$items[] = $HTML->wrap('li', $s);
}
$body .= $HTML->wrap('ul.dash-list', implode('', $items));
}
$body = $HTML->wrap('div.body', $body);
return $HTML->wrap('div.widget div.dash-content', $header.$body);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment