Drupal tip #3: Better display of weblink.module entries

This is another simple little trick. I've gotten asked a few times how I got the URLs to display on my weblink entries. For an example look below the body of this entry:

See the little globe icon with the URL? It's easy to modify the node.tpl.php to conditionally format weblink entries. Just check for the node type using this code:

<?php
   
if ($node->type == 'weblink') {
      print
'<a href="/drupal-4-7-2/'. $node->url .'">'. $node->url .'</a>';
    }
?>

Simple, no? You can do that with any type, e.g. page, blog, poll, etc.

Update Weitzman (Moshe?) gave another nice alternative: "Copy node.tpl.php to node-weblink.tpl.php. Then you can customize fiull display of each node type." Even simpler!

Comments

01 weitman
01/11/06 @ 10:18

an alternative is to copy node.tpl.php to node-weblink.tpl.php. then you can customize fiull display of each node type

02 jibbajabba
01/11/06 @ 12:35

Hey, that's an even better tip!

Advertisement

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <b> <strong> <dd> <dl> <dt> <i> <li> <ol> <u> <ul> <code> <blockquote>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options