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.

新しいコメントの投稿

このフィールドの内容は非公開にされ、公表されることはありません。
  • ウェブページアドレスとメールアドレスは、自動的にハイパーリンクに変換されます。
  • 使用できるHTMLタグ: <a> <em> <strong> <code> <cite> <ul> <ol> <li> <dl> <dt> <dd> <p>
  • 行と段落は自動的に折り返されます。
  • Amazon製品へのリンクを次の形式で作成することが出来ます。[amazon product_id inline|full|thumbnail]. 例: [amazon 1590597559 thumbnail]
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • 画像を追加することが出来ます。

書式オプションに関するより詳しい情報...

認証コード
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
画像で表示されている数字および記号を入力してください。