by John

Related Links is a very useful module for any Drupal content management application. Your content can display links to other content in a number of interesting and automated ways, such as based on the content type, the author, common taxonomy terms or keyword search results. But the most straight-forward method is for the author to manually create these links. A related link is created with a space separating the URL from the title:

    solutions Web Application Solutions

or

    http://google.com Goooogle

If the link is important enough to warrant this extra attention (and effort), we think it deserves a teaser line as well, like this:

    Web Application Solutions
    We specialize in helping organizations establish a solid, sustainable Information Architecture with a user-centered Web Strategy

While Related Links has no concept of teasers, we can stuff the teaser into the title and then separate the teaser back out on presentation. We will be using the pipe character (|) to delineate between title and teaser:

    solutions Web Application Solutions|We specialize in helping organizations establish a solid, sustainable Information Architecture with a user-centered Web Strategy

Finally, we need to override the theme_relatedlinks output, which will require all of one line of new code for the preg_replace. Place this code in your template.php file.

<?php
//override theme_relatedlinks for teaser support
function phptemplate_relatedlinks($links = array()) {
 
//capture pipe teaser and append
 
$links = preg_replace('/^(.*>.*)(\|)(.*)<\/a>$/', '\\1</a><div>\\3</div>', $links);
  return
theme('item_list', $links, $title);
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Highlighted PHP code can be posted with <?php ... ?> tags.

More information about formatting options

Captcha
We're only human... Captcha is a simple challenge-response test to make sure you are too.
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.