Oregon State University

Internal Links: CWS PathFilter Customization

First a definition: Any link to something inside of the Drupal site is an internal link. So, a link to a node, or file, or image in the site would be internal.

Drupal has no built in functionality for handling internal links to a site.

In order to handle the case where a site is developed on a different vhost or path from where the site will live in the end, RobRoy created PathFilter. PathFilter takes any instance of 'internal:' in a src or href and replaces it with either an absolute or relative link to the item specified when the node is displayed (configured in PathFilter settings).

In our implementation, we have modified the PathFilter module to automatically take any link with 'http(s)://server.hostname.com/path/to/drupal/install/' or '/path/to/drupal/install/' and replace it with 'internal:' when saved to the database.

On edit, all instances of 'internal:' are replaced with the appropriate relative or absolute link so WYSIWYG editors will function correctly. On view, all instances of 'internal:' are replaced with an absolute or relative link to the item. Always remember that they will be stored as 'internal:' in the database.

This process of translating links to 'internal:' should be transparent. There may be instances where an old node was created before this process was in use. Usually any node made before May 30th 2007 will need to be updated.

Example of Translation:

  • User edits a page and makes a link to "http://oregonstate.edu/webprojects/drupal/node/211"
  • On save, that link is converted to "internal:node/211" and stored into the database.
  • On edit, the link is converted back to "/webprojects/drupal/node/211".
  • On view of the node, the link is converted by default to "http://oregonstate.edu/webprojects/drupal/node/211".

Central Web Services, Oregon State University, Corvallis, OR 97331 · 541-737-1189
Contact us with your comments, questions and feedback
Copyright © 2007 Oregon State University | Disclaimer