Our site used to have working external links in the form [[http://mylink.domain|My Title]] but something changed, though I'm not sure it was freelinking. Perhaps we had been using another module to handle this. Anyway, my solution was to just create a freelinking plugin to handle the case. If this isn't incompatible with other modules, I'd love to see it included in an official release. It is here attached!

CommentFileSizeAuthor
freelinking_external.inc_.tar_.gz709 bytesthinkyhead

Comments

sfreese’s picture

This is a great addition. I'm not sure why they removed this functionality, either. Your plugin works great but there's a problem. If the external url is a complex one that includes arguments denoted by an equal sign (such as a link to a Google Form, for instance), it fails and passes the title to the search plugin. The problem seems to be in the freelinking_parse_target function of freelinking.module where it explodes the passed arguments on any equal sign:

if (strpos($item, '=')) {
 list($name, $value) = explode('=', $item);
 $args[$name] = $value;
}

I'm not much of a PHP developer so I can't quite figure out what this part of the function is for. None of the other plugins seem to make use of equal signs. Maybe you or another developer can help me sort this out. I really want my users to be able to harness freelinking for external links.

Thanks in advance.

  • gisle committed b1c484f on 7.x-3.x
    #1798542 by gisle: Added support for freelinks to arbitrary external...
gisle’s picture

Title: External Links plugin » Freelinks to external URLs
Version: 6.x-3.x-dev » 7.x-3.x-dev
Assigned: Unassigned » gisle
Issue summary: View changes
Status: Active » Needs review

Built-in support for freelinks to external URLs has been added to the HEAD of 7.x-3.x-dev.

You should now be able to use freelinking double brackets like these to link to external URLs:

[[https://groups.drupal.org/frontpage]]
[[https://www.google.com/search?q=waldo&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&channel=sb#safe=off&rls=org.mozilla:en-US:official&channel=sb&q=wally|Where is Wally?|Use Google to locate Wally!]]

Please review.

gisle’s picture

Version: 7.x-3.x-dev » 7.x-3.5
Status: Needs review » Fixed

This is included in the 7.x-3.5 release.

Status: Fixed » Closed (fixed)

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

thinkyhead’s picture

The code needed some tweaks to handle queries, fragments, and SSL. Here's the updated source:

/**
 * Freelinking External Plugin
 * 
 * @file
 *   Supports the creation of links by url
 * 
 *   Syntax:
 *     [[http://yourlink|Your Title]]
 *   or:
 *     [[https://yourlink|Your Title]]
 */
$freelinking['external'] = array(
  'indicator' => '/http/i',
  'callback' => 'freelinking_external_callback',
  'tip' => t('Link to an external URL.'),
  'failover' => array('search'),
  'protocol' => ''
);
$freelinking['external_ssl'] = array(
  'indicator' => '/https/i',
  'callback' => 'freelinking_external_callback',
  'tip' => t('Link to an external secure URL.'),
  'failover' => array('search'),
  'protocol' => 's'
);

function freelinking_external_callback($target, $plugin) {
  if (!preg_match('!^//.+!', $target['target'])) {
    $failover = variable_get('freelinking_external_failover', 'nodetitle');
    return array('failover' => $failover);
  }

  list($link, $title) = explode('|', "http$plugin[protocol]:$target[target]");
  return array($title ? $title : $link, $link);
}

gisle’s picture

Status: Closed (fixed) » Needs work

Reopening (I probably will not have time to look into this until 2015).

gisle’s picture

Version: 7.x-3.5 » 7.x-3.x-dev
Status: Needs work » Needs review

A revised plugin for external URLs has been pushed to the latest development snapshot of the 7.x-3.x-dev branch.

Please review.

gisle’s picture

Version: 7.x-3.x-dev » 7.x-3.6
Assigned: gisle » Unassigned
Status: Needs review » Fixed

This is now fixed in version 7.x-3.6 of Freelinking.

Note: Before updating to version 7.x-3.6, you should to enable the following module on your site: Advanced help hint.

Also, as part of updating, make sure you run the update script to make sure this required module is properly enabled.

Failing to do so will trigger the following error message when you try to visit some of the tabs in the admin GUI: Call to undefined function advanced_help_hint_docs() ...

Status: Fixed » Closed (fixed)

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