Skip to content

Instantly share code, notes, and snippets.

@Quilted
Created February 15, 2011 22:44
Show Gist options
  • Save Quilted/828430 to your computer and use it in GitHub Desktop.
Save Quilted/828430 to your computer and use it in GitHub Desktop.
Custom Panel Pane: This is for user pages, replace 'user' with node and replace artist_profile with your module.
<?php
/**
* Implementation of specially named hook_ctools_content_types()
*/
function artist_profile_share_ctools_content_types() {
return array(
'single' => TRUE,
'title' => t('Custom Share Links'),
'icon' => 'icon_node.png',
'description' => t('Displays Facebook Share button'),
'required context' => new ctools_context_required(t('Profile Owner'), 'user'),
'category' => t('Custom'),
);
}
function artist_profile_share_content_type_render($subtype, $conf, $panel_args, $context) {
$node = isset($context->data) ? drupal_clone($context->data) : NULL;
$items = array();
$output = '';
$block = new stdClass();
// dsm($context);
$domain = (isset($_SERVER['HTTP_HOST'])) ? 'http://' . preg_replace('`^www.`', '', $_SERVER['HTTP_HOST']) : 'http://artspan.org';
$path = drupal_get_path_alias('user/' . $context->argument);
$title = ($context->data->field_artist_name) ? $context->data->field_artist_name : $context->data->title; // Add other text here if you want (such as "[artist name] on ArtSpan")
$safe_title = str_replace(' ', '+', $title);
$output = '<a href="http://www.facebook.com/sharer.php?u=' . $domain . base_path() . $path . '&t=' . $safe_title . '"><img height="16" width="16" title="" alt="Facebook" src="' . $domain . base_path() . drupal_get_path('module', 'artist_profile') . '/images/facebook.png"> Share</a>';
$block->module = 'artist_profile';
$block->delta = 'unknown';
$block->content = $output;
// $block->content = theme('item_list', $items);
return $block;
}
function artist_profile_share_content_type_admin_title($subtype, $conf, $context) {
return t('Share');
}
function artist_profile_share_content_type_edit_form(&$form, &$form_state) {
// provide a blank form so we have a place to have context setting.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment