(Tutorial) Adding A Permalink

Drupal : Adding A Permalink

Adding A Permalink

I got the idea for today's post after I received an e-mail during the week from Colin who was wondering how I added a permalink, and then styled the links section so that everything (comments, read more, permalink etc.) lines up.

I thought this might be of general interest, so here's the answer.

It's basically just a two step process:

  • add some markup to the node.tpl.php file
  • add some css to the style.css file

Step 1 - Add markup to the node.tpl.php file

To start with I just added some markup to the links div, and then positioned the whole links div at the end of my node.tpl.php file, right before the closing node div tag.

  
<?php if ($links): ?>
   <div class="links">
      <p class="permalink"><a href="<?php print $node_url ?>" title="Permalink to this my Drupal blog post">Permalink</a></p>
      <?php print $links ?> 
   </div>
   <?php endif; ?>

This positioned the permalink within the links div before the other links.

Courtesy: Mydrupalblog.lhmdesign.com