Skip to content

Instantly share code, notes, and snippets.

@jhedstrom
Created March 18, 2014 22:38
Show Gist options
  • Save jhedstrom/9631346 to your computer and use it in GitHub Desktop.
Save jhedstrom/9631346 to your computer and use it in GitHub Desktop.
A CTools content type plugin for the achievements module
<?php
/**
* @file
* Per-user badges/achievements CTools content type plugin.
*/
/**
* The Achievements plugin definition.
*/
$plugin = array(
'title' => t('Achievements by user'),
'category' => t('A sensible category'),
'description' => t('A user\'s earned badges.'),
'required context' => new ctools_context_required(t('User'), 'user'),
);
/**
* CTools content type output function.
*/
function MYMODULE_achievements_content_type_render($subtype, $conf, $panels_args, $context) {
if (empty($context) || empty($context->data)) {
return;
}
// Build the custom content pane.
$pane = new stdClass();
$pane->module = 'vista_';
$pane->title = t('Badges');
// Use the achievement module's user page.
module_load_include('inc', 'achievements', 'achievements.pages');
$pane->content = achievements_user_page($context->data);
return $pane;
}
/**
* Pane admin form.
*/
function MYMODULE_achievements_content_type_edit_form($form, &$form_state) {
// No additional config.
return $form;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment