2013-05-16 56 views
0

您好我想創建爲Drupal尋呼機6創建2個鏈接L(),而不是一個爲Drupal 6加2鏈接類

我有這個功能來創建一個尋呼機

function mytheme_prev_next($current_node = NULL, $op = 'p') 
{ 
    // Node types to include in paging 
    $node_types = array('type'); 

    if ($op == 'p') { 
     $sql_op = '<'; 
     $order = 'DESC'; 
    } elseif ($op == 'n') { 
     $sql_op = '>'; 
     $order = 'ASC'; 
    } else { 
     return NULL; 
    } 

    $output = NULL; 
    foreach($node_types as $type) { 
     $quoted_types[] = "'" . $type . "'"; 
    } 
    $sql = "SELECT nid, title, created FROM {node} n 
      WHERE created $sql_op %s 
      AND type IN (" . implode(',', $quoted_types) . ") 
      AND status = 1 
      ORDER BY created $order 
      LIMIT 1"; 
    $result = db_query($sql, $current_node->created, $type); 
    $data = db_fetch_object($result); 
    if (!isset($data->nid) || !$data->nid) { 
     return NULL; 
    } 
    $options = array('attributes' => array('class' => 'prev')); 
    return l($data->title, "node/$data->nid", $options , array('html' => TRUE)); 
} 

基本上我所要做的是打破了這一點到2L()仍然顯示相同的信息,我只需要一個不同的鏈路類添加到它們時,該功能在主題模板的功能

<a href class="prev"><span class="arrowLeft"><?php print mytheme_prev_next($node, 'p'); ?></span></a> 
<a href class="next"><span class="arrowRight"><?php print mytheme_prev_next($node, 'n'); ?></span></a> 

的HTML上面的標記是什麼,我想實現

回答

0

返回的HTML字符串,而不是L()

// Instead of using the l() 
if ($op == 'p') { 
return '<a href="node/' . $data->nid . '" class="prev"><span class="arrowLeft"></span>   
</a>'; 
} else { 
return '<a href="node/' . $data->nid . '" class="next"><span class="arrowRight"></span> 
</a>'; 
}