0

我创建了一个内容类型,它有很多节点。并编写自定义模块以在首页上显示。

我的节点顺序:

 $themeurl = '/drupal/'.path_to_theme().'/images';
    $sql = "SELECT * FROM `node`
            LEFT JOIN `field_data_field_anasayfa_catwalk` ON `field_data_field_anasayfa_catwalk`.`entity_id` = `node`.`nid`
            WHERE type = 'designers_albums'
            AND `node`.`status` = 1
            AND `node`.`language` = '".$language->language."'
            AND `field_data_field_anasayfa_catwalk`.`field_anasayfa_catwalk_value` = 1
            ORDER BY `node`.`created` ASC";

但是现在,安装了权重模块并希望按重量排序。如何更改此选项?谢谢你。

4

1 回答 1

3

实体(节点)权重存储在weight_weights数据库表中。你可以试试那个查询

     $sql = "SELECT * FROM `node`
        LEFT JOIN `field_data_field_anasayfa_catwalk` ON `field_data_field_anasayfa_catwalk`.`entity_id` = `node`.`nid`
        LEFT JOIN `weight_weights` AS w ON w.entity_id=`node`.`nid`
        WHERE type = 'designers_albums'
        AND `node`.`status` = 1
        AND `node`.`language` = '".$language->language."'
        AND `field_data_field_anasayfa_catwalk`.`field_anasayfa_catwalk_value` = 1
        ORDER BY w.weight, `node`.`created` ASC";

顺便说一句,将来您应该考虑学习 Drupal 数据库抽象层或 EntityFieldQuery。

于 2013-01-17T15:52:35.697 回答