0

I am using the "Link" field in Drupal 7 to store links. Sometimes these links are internal and sometimes they are external. In the case of internal links, I would like to be able to store the system URL ("node/371") instead of an alias ("about/mission-statement") so that the link field will auto-correct itself when someone changes the URL alias.

Entity Reference is great for keeping track of internal nodes, but I would like the same field instance to handle both internal and external links.

Advanced Link doesn't seem to do this processing either.

Is there another module I should use, or a hook I can use to intercept the link field processing pre-storage?

EDIT

I was able to hack the module to get the behavior I wanted by adding two lines of code to _link_process :

$systemPath = drupal_lookup_path('source',$item['url']);
$item['url'] = ($systemPath) ? $systemPath : $item['url'];

… although it would be nice to be able to do this in a way that preserves an upgrade path.

2 Answers 2

0

That's a pretty small hack, and probably fairly easy to keep track of, but as you likely know it's probably not a good idea for a variety of reasons.

Another option: The Link checker module. It has a setting for "Update permanently moved links" (see below).

enter image description here

So after your internal page moves, Link checker will automatically change the link to the new alias for you (depending on what you choose for the fail threshold).

1
  • You're right -- changing code in the module is not ideal. This seems like a pretty solid strategy, and a good alternative to hacking. Aug 28, 2013 at 14:19
0

I use pathauto. it should automatically keep up with your node name changes and point to the right internal ref, right?

Then there's Node redirect?

Extended path alias might be promising, too. Extended path aliases

1
  • I don't think any of those do much more than set up a pattern for paths or enforce path aliasing; they don't help internal links self-heal. Mar 15, 2013 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.