php - 创建 2 个链接 l() 而不是 drupal 6 的一个以添加 2 个链接类

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

最佳答案

返回 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>';
}

关于php - 创建 2 个链接 l() 而不是 drupal 6 的一个以添加 2 个链接类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16597640/

相关文章:

drupal - Drupal 节点标题中的 HTML\富文本?

PHP MessDetector 给出的字段修饰符无效

javascript - Bootstrap 可编辑不遵循 PHP 创建表 `while`

php - 防止 imagecreatefromjpeg 停止脚本

MySql Select 和 SUM 问题

php - 将数据插入表 : Escaped Quotes? 时出现 Drupal DB 错误

drupal - Drupal 7 是否有比 Drupal 6 更好的方式来管理开发变更?

php - 将javascript函数的值插入数据库

mysql - 连接到 MySQL 数据库并计算行数

php - 从数据库中选择日期时间