function area_print_form in Area Print 6
Same name and namespace in other branches
- 7 area_print.module \area_print_form()
Implements hook_form().
Parameters
$options: An associative array containing: (optional) target_id: Id of the element you want to print, (optional) button_id: Id that will be given to the print link or button, (optional) value: The text for the link/button, eg. t('Print'), (optional) type: either 'link' or 'button', (optional) custom_css: path to a css file that will get added to the page before printing, eg. drupal_get_path('module','my_module').'/css/print.css'
Return value
Returns the rendered HTML for the print button/link.
1 call to area_print_form()
- area_print_example_page in area_print_example/
area_print_example.module
File
- ./
area_print.module, line 22 - Area Print module-file.
Code
function area_print_form($options = array()) {
drupal_add_js(drupal_get_path('module', 'area_print') . '/area_print.js');
drupal_add_js(drupal_get_path('module', 'area_print') . '/jquery.ba-untils.js');
$default_options = array(
'button_id' => 'area_print_button',
'target_id' => 'content',
'value' => t('Print'),
'type' => 'button',
'hide_button' => FALSE,
'custom_css' => 'none',
);
$options = array_merge($default_options, $options);
$js_options = array(
'button_id' => $options['button_id'],
'target_id' => $options['target_id'],
'custom_css' => $options['custom_css'],
'hide_button' => $options['hide_button'],
);
drupal_add_js(array(
'area_print' => $js_options,
), 'setting');
switch ($options['type']) {
case 'button':
$form['print_button'] = array(
'#id' => $options['button_id'],
'#type' => 'button',
'#value' => $options['value'],
);
break;
case 'link':
$form['print_link'] = array(
'#id' => $options['button_id'],
'#type' => 'markup',
'#value' => "<a href='#' id='" . $options['button_id'] . "'>" . $options['value'] . "</a>",
);
break;
}
return drupal_render($form);
}