Skip to content

Instantly share code, notes, and snippets.

@fieke
Created September 26, 2013 14:17
Show Gist options
  • Save fieke/6714861 to your computer and use it in GitHub Desktop.
Save fieke/6714861 to your computer and use it in GitHub Desktop.
Implement hook_form_alter // Ontvang PDF via email
function theme_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'webform_client_form_9':
// send along url with contact form
$form['submitted']['location']['#value'] = request_path();
break;
case 'webform_client_form_47':
// create return link to product
if (isset($_GET['nid'])) {
// load product node
$node = node_load($_GET['nid']);
// create backlink
$form['#prefix'] = l(t('Return to ' . $node->title), 'node/' . $node->nid, array('attributes' => array('class' => array('pdf-backlink'))));
// fill in location
$form['submitted']['location']['#value'] = l($node->title, 'node/' . $node->nid);
}
break;
}
}
/**
* Implements hook_node_view().
*/
function theme_node_view($node, $view_mode, $langcode) {
switch ($node->type) {
case 'property':
if ($view_mode == 'full') {
// Create link to Download PDF page
global $language;
switch ($language->language) {
case 'fr':
$link = 'node/55';
break;
default:
$link = 'node/48';
break;
}
$node->content['download_pdf']['#markup'] = l(t('Download PDF'), $link, array('query' => array('nid' => arg(1)), 'attributes' => array('class' => array('dl-pdf'))));
}
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment