The Source URL and Links inside the exported PDF needs to be rendered as Hyperlinks to be correctly usefull, verifying the code print.pages.inc was found that this was returning the tag P not an hyperlink: "<p><strong>" . t('Links') . "</strong><br />$url_list</p>"; The main problem is if we try to generate a pdf and the path is too long the line will break and the path will be cutted invalidating the same. Another point found is that for the adobe and other tools that render pdf files if the path isn't a hyperlink this will not be clickable, i have attached the code with some modification into the print.pages.inc file, if you guys could please review it i will appreciatte,

/**
 * Returns HTML for the source URL line of the print template.
 *
 * @param array $vars
 *   An associative array containing:
 *   - $url: the URL to the full node view.
 *   - $node: the node object.
 *   - $cid; comment ID of the comment to display.
 *
 * @return string
 *   HTML text with the footer
 *
 * @ingroup themeable
 * @ingroup print_themeable
 */
function theme_print_sourceurl($vars) {
  $sourceurl_date = variable_get('print_sourceurl_date', PRINT_SOURCEURL_DATE_DEFAULT);
  $url = is_int($vars['cid']) ? $vars['url'] . '#comment-' . $vars['cid'] : $vars['url'];

  $output = '<strong>' . t('Source URL');
  if ($sourceurl_date && isset($vars['node'])) {
    $output .= ' (';
    $date = format_date($vars['node']->changed, 'short');

    $output .= empty($vars['node']->nid) ? t('retrieved on !date', array('!date' => $date)) : t('modified on !date', array('!date' => $date));

    $output .= ')';
  }
  $new_url = explode("base_url", $url);
  $output .= ':</strong>' ."<a href=".$new_url[1].">". $url . '</a>';

  return $output;
}

/**
 * Returns HTML for the URL list of the print template.
 *
 * @param array $vars
 *   An empty associative array
 *
 * @return string
 *   HTML text with the URL list
 *
 * @ingroup themeable
 * @ingroup print_themeable
 */
function theme_print_url_list($vars) {
  global $_print_urls;

  // Display the collected links at the bottom of the page. Code once taken from Kjartan Mannes' project.module
  if (!empty($_print_urls)) {
    $urls = _print_friendly_urls();
    $max = count($urls);
    $url_list = '';
    foreach ($urls as $key => $url) {
      drupal_alter('print_url_list', $url);
      $new_url = explode("base_url", $url);
      $url_list .= "<a href=".$new_url[1]." target='_blank'>". '[' . ($key + 1) . '] ' . check_plain($url) . "</a>\n";
    }
    if (!empty($url_list)) {
      return "<p><strong>" . t('Links') . "</strong><br />$url_list</p>";
    }
    else {
      return '';
    }
  }
}

Thanks,

Vitor.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Vitor Grillo created an issue. See original summary.

Vitor Grillo’s picture

Issue summary: View changes
Vitor Grillo’s picture

Vitor Grillo’s picture

Don't use this patch, submitted wrong.

Vitor Grillo’s picture

Follow new patch with the $base_url fixed.

Vitor Grillo’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Assigned: Vitor Grillo » Unassigned
renatog’s picture

Status: Needs review » Reviewed & tested by the community

I applied patch #5 and really works good.

#RTBC

  • RenatoG committed 06451dd on 7.x-2.x authored by Vitor Grillo
    Issue #2897361 by Vitor Grillo, RenatoG: Source URL and Links needs to...
renatog’s picture

Status: Reviewed & tested by the community » Fixed

Committed to the dev branch.

Thank you very much for your contribution, @vitor-grillo.

Best,

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.