Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When nodes have multiple taxonomy terms attached, are orderable in multiple categories, changing the order doesn't work.
This turns out to be because the term id is not taken into account when fetching the weights (in the nodeorder_node_load function), causing the weights of the nodes associated with others terms to overwrite the correct weight.
I rewrote the nodeorder_node_load function in nodeorder.module as following to fix this :
function nodeorder_node_load($nodes, $types) {
if (arg(0) == 'taxonomy' && arg(1) == 'term' && arg(2)) $tid = arg(2);
else $tid = '';
$query = db_select('taxonomy_index', 't')
->condition('nid', array_keys($nodes), 'IN');
if ($tid) $query->condition('tid', $tid);
$result = $query
->fields('t', array('weight', 'nid'))
->execute();
foreach ($result as $record) {
$nodes[$record->nid]->weight = $record->weight;
}
}
Comment | File | Size | Author |
---|---|---|---|
#1 | nodeorder-node-multiple-terms-1883038-1.patch | 788 bytes | mfernea |
Comments
Comment #1
mfernea CreditAttribution: mfernea commentedI have the same issue and I also think that nodeorder_node_load should be modified. The patch is based on the code posted by syngi. I think that the function should do nothing if the node load doesn't happen in a page related to a term.
Comment #3
dieuwe