为drupal 6创建2个链接l()而不是一个,以添加2个链接类

时间:2013-05-16 21:16:44

标签: php mysql drupal-6

您好我正在尝试为drupal 6创建一个寻呼机

我有这个功能来创建一个寻呼机

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));
}

基本上我要做的就是把它分解成2个l()函数,它们仍然显示相同的信息我只需要为它们添加不同的链接类这是主题模板中的一个函数

<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标记就是我想要实现的目标

1 个答案:

答案 0 :(得分: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>';
}