Created
July 21, 2018 12:31
-
-
Save husseinalhammad/ab59aab7f9d3cd40c700252e6c4e48df to your computer and use it in GitHub Desktop.
Perch Members - dashboard widget example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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