Skip to content

Instantly share code, notes, and snippets.

@ribel
Created May 3, 2013 08:09
Show Gist options
  • Save ribel/5507849 to your computer and use it in GitHub Desktop.
Save ribel/5507849 to your computer and use it in GitHub Desktop.
Drupal PHP
ctools_include('ajax');
ctools_include('modal');
ctools_modal_add_js();
$custom_style = array(
'espn-style' => array(
'modalSize' => array(
'type' => 'fixed',
'width' => 850,
'height' => 525,
'contentBottom' => 75
),
'animation' => 'fadeIn',
),
);
drupal_add_js($custom_style, 'setting');
$athlete_add_path = empty($discipline) ?
'event/' . $event->eid . '/nojs/athlete/add' :
'event/' . $event->eid . '/nojs/discipline/' . $discipline->did . '/athlete/add';
$output[] = array(
'#prefix' => '<div class="modal-button">',
'#markup' => ctools_modal_text_button(t('Add Athlete'), $athlete_add_path, t('Add Athlete'), 'ctools-modal-espn-style btn'),
'#suffix' => '</div>',
);
$items['event/%event/%ctools_js/athlete/add'] = array(
'title' => 'Add Athlete',
'page callback' => 'event_athlete_add',
'page arguments' => array(1, 2),
'access arguments' => array('administer event'),
'type' => MENU_LOCAL_ACTION,
'file' => 'event_athlete.pages.inc',
);
/**
* A modal login callback.
*/
function event_athlete_add($event, $js = NULL, $discipline = NULL) {
$form_state = array(
'event' => $event,
'discipline' => $discipline,
);
if(!$js) {
return drupal_build_form('event_athlete_add_form', $form_state);
}
ctools_include('modal');
ctools_include('ajax');
$form_state += array(
'title' => t('Add Athlete'),
'ajax' => TRUE,
);
$output = ctools_modal_form_wrapper('event_athlete_add_form', $form_state);
if (!empty($form_state['executed'])) {
// We'll just overwrite the form output if it was successful.
$output = array();
$output[] = ctools_modal_command_dismiss('Success');
}
print ajax_render($output);
exit;
dpm(field_info_field('field_test'));
dpm(field_info_instance('node', 'field_test', 'content_type_test'));
$node->content['facebook_share'] = array(
'#theme' => 'html_tag',
'#tag' => 'iframe',
'#attributes' => array(
'src' => $fb_src,
'scrolling' => 'no',
'frameborder' => 0,
'style' => 'border:none; overflow:hidden; width:250px; height:21px;',
'allowTransparency' => 'true'
),
);
$fb_src = url('http://www.facebook.com/plugins/like.php', array('external' => TRUE, 'html' => TRUE,
'query' => array('href' => $share_url, 'send' => 'false', 'layout' => 'button_count', 'width' => 250,
'show_faces' => 'false', 'action' => 'like', 'colorscheme' => 'light', 'font' => 'arial', 'height' => 21)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment