2012-01-31 72 views
0

請原諒,如果這個問題有一個簡單的答案。找出使用哪個鉤子

我正在做一個類似於nodereferences_url的模塊。

任何人都可以告訴我哪個Drupal掛鉤實現將鏈接放入鏈接到節點內容區域,如附加圖像中突出顯示的那樣?

謝謝!

enter image description here

回答

0

它是hook_link(),其被描述爲:

該鉤子能夠模塊鏈接添加到Drupal的許多地方。例如,鏈接可以添加到節點或導航塊中。

返回的數組應該是鏈接條目的鍵控數組。每個鏈接可以是兩種格式之一。

執行該鉤的一個例子是node_link(),包含下面的代碼:

function node_link($type, $node = NULL, $teaser = FALSE) { 
    $links = array(); 

    if ($type == 'node') { 
    if ($teaser == 1 && $node->teaser && !empty($node->readmore)) { 
     $links['node_read_more'] = array(
     'title' => t('Read more'), 
     'href' => "node/$node->nid", 
     // The title attribute gets escaped when the links are processed, so 
     // there is no need to escape here. 
     'attributes' => array('title' => t('Read the rest of !title.', array('!title' => $node->title))), 
    ); 
    } 
    } 

    return $links; 
} 

那就是添加了「更多」中的一個節點的預告片的鏈接,當代碼節點內容超過了預告中已經顯示的內容。

注意鉤子被調用的節點和註釋。如文檔中所述,$type參數可以具有以下值:

  • 「comment」:鏈接位於正在查看的評論下方。
  • 「節點」:鏈接放置在正在查看的節點下。
+0

謝謝,那正是我一直在尋找的! – sisko 2012-02-01 12:29:40

相關問題