fieke
9/26/2013 - 2:17 PM

Implement hook_form_alter // Ontvang PDF via email

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;
  }
}