我创建了一个内容类型,它有很多节点。并在首页上编写自定义模块进行展示。
我的节点订购:
$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";
但是现在,安装了重量模块,并希望按重量排序。我该如何更改此选项?谢谢。
答案 0 :(得分: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。