Changing the order of 'links'
in

Seemingly a simple thing is very hard to do sometimes in Drupal. One thing is to change the order of node's links. For example, the main page lists node's teaser, where each node teaser is followed by links like "Nobu's blog", "Add new comments", and "Read More".

For readers, it may be natural to continue to read by clicking 'Read More'. Since 'Read More' is NOT the first link, one may be mislead that there's no contents for the node. To avoid this, I wanted to show "Read More" immediately below the teaser, not as part of many links.

To do this, you need to implement a hook function. In theme's folder, you find template.php. If not, you need to create one. In the file, I implemented the way to show "Read More" first, then rest of the links.

function phptemplate_links($links, $attributes = array()) {
   
//do whatever to links here
   
$my_links = array();
   
   
// Take out 'Read More'.
   
if(isset($links['node_read_more']))
    {
     
$my_links['node_read_more'] = $links['node_read_more'];
      unset(
$links['node_read_more']);
    }
   
   
// Show the 'Read More' first.
   
$theme1 = theme_links($my_links, $attributes);

   
// Then, the rest of links
   
$theme2 = theme_links($links, $attributes);

    return
$theme1 . $theme2;
   
}

Depending on the theme, you may want to change attributes so that you can show using different style in CSS.

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> <code> <cite> <ul> <ol> <li> <dl> <dt> <dd> <p>
  • Lines and paragraphs break automatically.
  • Link to Amazon products with: [amazon product_id inline|full|thumbnail]. Example: [amazon 1590597559 thumbnail]
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Images can be added to this post.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.